public TypeDefinition resolveClassName(JsString qualifiedClassName) { dynamic type = findDefinition(qualifiedClassName); if (type == null) { JsString classDefinition = loader.loadClass(qualifiedClassName); //Before we load it into memory, check on the super class and see if we need to load *that* //into memory. We may *NOT* have an inherit if we dont inherit from anything, that is just fine resolveParentClassFromDefinition(qualifiedClassName,classDefinition); //Load the newly found class memory addDefinition(classDefinition); //Get a reference to the newly added type type = findDefinition(qualifiedClassName); if (type == null) { //This alert shouldnt be here, we should figure out a way to get it to the UI level HtmlContext.alert(qualifiedClassName + " does not contain required injection information "); throw new JsError(qualifiedClassName + " does not contain required injection information "); } var td = new TypeDefinition(type); if (!td.builtIn) { //Finally, resolve any classes it references in its own code execution resolveClassDependencies(td); } } return new TypeDefinition(type); }
internal override AbstractBinding getBinding(TypeDefinition typeDefinition) { //First we try to resolve it on our own, without own AbstractBinding AbstractBinding abstractBinding = binder.getBinding(typeDefinition); //if we do not have a specific AbstractBinding for it, we need to check to see if our parent injector has a specific AbstractBinding for it before we just go building stuff if (abstractBinding == null) { abstractBinding = parentInjector.getBinding(typeDefinition); } return abstractBinding; }
public void verifyAndRegister() { foreach (var id in viableInjectionPoints) { if (viableInjectionPoints[id].As<JsString>() == "req") { dynamic instance = this; var typeDefinition = new TypeDefinition(instance.constructor); HtmlContext.alert(typeDefinition.getClassName() + " requires a [View] element with the id of " + id + " but it could not be found"); return; } JsContext.delete(viableInjectionPoints[id]); } this.viableInjectionPoints = null; onRegister(); }
//Entry point for TypeAbstractBinding to ask for a class.... //This method does so without trying to resolve the class first, which is important if we are called from within a resolution public object buildClass(TypeDefinition typeDefinition) { object instance; if (typeDefinition.builtIn) { instance = typeDefinition.constructorApply(null); } else { var constructorPoints = typeDefinition.getConstructorParameters(); instance = buildFromInjectionInfo(typeDefinition, constructorPoints); var fieldPoints = typeDefinition.getInjectionFields(); injectMemberPropertiesFromInjectionInfo(instance, fieldPoints); var methodPoints = typeDefinition.getInjectionMethods(); injectMembersMethodsFromInjectionInfo(instance, methodPoints); } return instance; }
public BindingFactory(Binder binder, TypeDefinition typeDefinition) { this.binder = binder; this.typeDefinition = typeDefinition; }
protected JsString getName(JsObject instance) { var dependency = new TypeDefinition(instance["constructor"]); return dependency.getClassName(); }
public InstanceAbstractBinding(TypeDefinition typeDefinition, object instance) { this.typeDefinition = typeDefinition; this.instance = instance; }
private JsObject<object> getBehaviorInjectionPoints() { dynamic jsInstance = this; var map = new JsObject<object>(); var typeDefinition = new TypeDefinition(jsInstance.constructor); JsArray<InjectionPoint> viewPoints = typeDefinition.getViewFields(); for (int i = 0; i < viewPoints.length; i++) { if (viewPoints[i].r == 0) { map[viewPoints[i].n] = "opt"; } else { map[viewPoints[i].n] = "req"; } } return map; }
public ProviderAbstractBinding(TypeDefinition typeDefinition, TypeDefinition providerTypeDefinition) { this.typeDefinition = typeDefinition; this.providerTypeDefinition = providerTypeDefinition; }
private void resolveClassDependencies(TypeDefinition type) { var classDependencies = type.getClassDependencies(); for ( var i=0; i<classDependencies.length; i++) { resolveClassName(classDependencies[i]); } }
public void injectMembers(dynamic instance) { Type constructor = instance.constructor; var typeDefinition = new TypeDefinition(constructor); var fieldPoints = typeDefinition.getInjectionFields(); injectMemberPropertiesFromInjectionInfo(instance, fieldPoints); var methodPoints = typeDefinition.getInjectionMethods(); injectMembersMethodsFromInjectionInfo(instance, methodPoints); }
public object getInstance(TypeDefinition dependencyTypeDefinition) { return resolveDependency(dependencyTypeDefinition); }
object resolveDependency(TypeDefinition typeDefinition) { AbstractBinding abstractBinding = null; if ( !typeDefinition.builtIn ) { abstractBinding = getBinding(typeDefinition); } object instance; if (abstractBinding != null) { instance = abstractBinding.provide(this); } else { instance = buildClass(typeDefinition); } return instance; }
object buildFromInjectionInfo(TypeDefinition dependencyTypeDefinition, JsArray<InjectionPoint> constructorPoints) { var args = new JsArray<object>(); for (int i = 0; i < constructorPoints.length; i++) { args[i] = resolveDependency(classResolver.resolveClassName(constructorPoints[i].t)); } object obj = dependencyTypeDefinition.constructorApply(args); return obj; }
internal virtual AbstractBinding getBinding( TypeDefinition typeDefinition ) { return binder.getBinding( typeDefinition ); }
public TypeAbstractBinding(TypeDefinition typeDefinition, TypeDefinition dependencyDefinition) { this.typeDefinition = typeDefinition; this.dependencyDefinition = dependencyDefinition; }