public ChildInjector(Binder binder, ClassResolver classResolver, Injector parentInjector) : base(binder, classResolver) { this.parentInjector = parentInjector; //Child injectors set themselves up as the new default Injector for the tree below them binder.bind(typeof(Injector)).toInstance(this); }
public Injector createInjector(GuiceModule module) { var hashMap = new BindingHashMap(); var binder = new Binder( hashMap ); var loader = new SynchronousClassLoader(new XMLHttpRequest(), "generated/"); var classResolver = new ClassResolver( loader ); if (module != null) { module.configure(binder); } var injector = new Injector(binder, classResolver); binder.bind(typeof(Injector)).toInstance(injector); binder.bind(typeof(ClassResolver)).toInstance(classResolver); binder.bind(typeof(SynchronousClassLoader)).toInstance(loader); return injector; }
/* * This was always a bad idea... i have simply finally talked myself out of it [JsMethod(NativeParams=false)] public object buildClass(JsString className, params object[] list) { object instance; TypeDefinition typeDefinition = classResolver.resolveClassName( className ); //this feels like it needs to be refactored instance = typeDefinition.constructorApply(list); injector.injectMembers(instance); return instance; }*/ public InjectionClassBuilder(Injector injector, ClassResolver classResolver) { this.injector = injector; this.classResolver = classResolver; }