/// <summary> /// Register the given factory delegate to be called when the container is /// asked to resolve <typeparamref name="=TTypeToBuild"/> and <paramref name="name"/>. /// </summary> /// <typeparam name="TTypeToBuild">Type that will be requested from the container.</typeparam> /// <param name="name">The name that will be used when requesting to resolve this type.</param> /// <param name="factoryMethod">Delegate to invoke to create the instance.</param> /// <returns>The container extension object this method was invoked on.</returns> public IStaticFactoryConfiguration RegisterFactory <TTypeToBuild>( string name, FactoryDelegate factoryMethod) { FactoryBuildPlanDelegate planDelegate = delegate { return(factoryMethod(Container)); }; Context.Policies.Set <IBuildPlanPolicy>( new FactoryDelegateBuildPlanPolicy(planDelegate), NamedTypeBuildKey.Make <TTypeToBuild>(name)); return(this); }
public FactoryDelegateBuildPlanPolicy(FactoryBuildPlanDelegate factory) { this.factory = factory; }