refactor(core): separate reflective injector from Injector interface

BREAKING CHANGE:
- Injector was renamed into `ReflectiveInjector`,
  as `Injector` is only an abstract class with one method on it
- `Injector.getOptional()` was changed into `Injector.get(token, notFoundValue)`
  to make implementing injectors simpler
- `ViewContainerRef.createComponent` now takes an `Injector`
  instead of `ResolvedProviders`. If a reflective injector
  should be used, create one before calling this method.
  (e.g. via `ReflectiveInjector.resolveAndCreate(…)`.
This commit is contained in:
Tobias Bosch
2016-04-14 12:35:24 -07:00
parent efbd446d18
commit 0a7d10ba55
46 changed files with 1790 additions and 1719 deletions

View File

@ -12,7 +12,7 @@ import {
SpyObject
} from 'angular2/testing_internal';
import {Injector, provide} from 'angular2/core';
import {Injector, provide, ReflectiveInjector} from 'angular2/core';
import {CONST_EXPR} from 'angular2/src/facade/lang';
import {Location, LocationStrategy, APP_BASE_HREF} from 'angular2/platform/common';
@ -26,7 +26,7 @@ export function main() {
function makeLocation(baseHref: string = '/my/app', provider: any = CONST_EXPR([])): Location {
locationStrategy = new MockLocationStrategy();
locationStrategy.internalBaseHref = baseHref;
let injector = Injector.resolveAndCreate(
let injector = ReflectiveInjector.resolveAndCreate(
[Location, provide(LocationStrategy, {useValue: locationStrategy}), provider]);
return location = injector.get(Location);
}