refactor(di): move all binding resolution logic into injector.js
This commit is contained in:
25
modules/angular2/src/di/binding.js
vendored
25
modules/angular2/src/di/binding.js
vendored
@ -3,7 +3,7 @@ import {List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
import {Key} from './key';
|
||||
import {Inject, InjectLazy, InjectPromise, Optional, DependencyAnnotation} from './annotations';
|
||||
import {NoAnnotationError, InvalidBindingError} from './exceptions';
|
||||
import {NoAnnotationError} from './exceptions';
|
||||
|
||||
export class Dependency {
|
||||
key:Key;
|
||||
@ -88,29 +88,6 @@ export class Binding {
|
||||
isAsync
|
||||
);
|
||||
}
|
||||
|
||||
static resolveAll(bindings:List): List {
|
||||
var resolvedList = ListWrapper.createFixedSize(bindings.length);
|
||||
for (var i = 0; i < bindings.length; i++) {
|
||||
var unresolved = bindings[i];
|
||||
var resolved;
|
||||
if (unresolved instanceof ResolvedBinding) {
|
||||
resolved = unresolved; // ha-ha! I'm easily amused
|
||||
} else if (unresolved instanceof Type) {
|
||||
resolved = bind(unresolved).toClass(unresolved).resolve();
|
||||
} else if (unresolved instanceof Binding) {
|
||||
resolved = unresolved.resolve();
|
||||
} else if (unresolved instanceof List) {
|
||||
resolved = Binding.resolveAll(unresolved);
|
||||
} else if (unresolved instanceof BindingBuilder) {
|
||||
throw new InvalidBindingError(unresolved.token);
|
||||
} else {
|
||||
throw new InvalidBindingError(unresolved);
|
||||
}
|
||||
resolvedList[i] = resolved;
|
||||
}
|
||||
return resolvedList;
|
||||
}
|
||||
}
|
||||
|
||||
/// Dependency binding with resolved keys and dependencies.
|
||||
|
Reference in New Issue
Block a user