public InjectionFutureImpl(T instance) { this.injector = null; this.iface = null; this.instance = instance; }
private static InjectorImpl Copy(InjectorImpl old, IConfiguration[] configurations) { InjectorImpl injector = null; try { IConfigurationBuilder cb = old.configuration.newBuilder(); foreach (IConfiguration c in configurations) { cb.AddConfiguration(c); } injector = new InjectorImpl(cb.Build()); } catch (BindException e) { Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Unexpected error copying configuration!", e), LOGGER); } foreach (IClassNode cn in old.instances.Keys) { if (cn.GetFullName().Equals(ReflectionUtilities.GetAssemblyQualifiedName(typeof(IInjector))) || cn.GetFullName().Equals(ReflectionUtilities.GetAssemblyQualifiedName(typeof(InjectorImpl)))) { // This would imply that we're treating injector as a singleton somewhere. It should be copied fresh each time. Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException(""), LOGGER); } try { IClassNode new_cn = (IClassNode)injector.classHierarchy.GetNode(cn.GetFullName()); object o = null; old.instances.TryGetValue(cn, out o); if (o != null) { injector.instances.Add(new_cn, o); } } catch (BindException e) { Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new IllegalStateException("Could not resolve name " + cn.GetFullName() + " when copying injector", e), LOGGER); } } foreach (INamedParameterNode np in old.namedParameterInstances.Keys) { // if (!builder.namedParameters.containsKey(np)) { Object o = null; old.namedParameterInstances.TryGetValue(np, out o); INamedParameterNode new_np = (INamedParameterNode)injector.classHierarchy.GetNode(np.GetFullName()); injector.namedParameterInstances.Add(new_np, o); } // Fork the aspect (if any) if (old.aspect != null) { injector.BindAspect(old.aspect.CreateChildAspect()); } return(injector); }
//public InjectionFuture() //{ // injector = null; // iface = null; // instance = null; //} public InjectionFutureImpl(IInjector injector, Type iface) { this.injector = (InjectorImpl)injector; this.iface = iface; this.instance = default(T); }