/// <summary> /// Remove policies associated with building this type. This removes the /// compiled build plan so that it can be rebuilt with the new settings /// the next time this type is resolved. /// </summary> /// <param name="typeToInject">Type of object to clear the plan for.</param> /// <param name="name">Name the object is being registered with.</param> private void ClearExistingBuildPlan(Type typeToInject, string name) { var buildKey = new NamedTypeBuildKey(typeToInject, name); DependencyResolverTrackerPolicy.RemoveResolvers(policies, buildKey); policies.Set <IBuildPlanPolicy>(new OverriddenBuildPlanMarkerPolicy(), buildKey); }
/// <summary> /// Remove policies associated with building this type. This removes the /// compiled build plan so that it can be rebuilt with the new settings /// the next time this type is resolved. /// </summary> /// <param name="typeToInject">Type of object to clear the plan for.</param> /// <param name="name">Name the object is being registered with.</param> private void ClearExistingBuildPlan(Type typeToInject, string name) { NamedTypeBuildKey buildKey = new NamedTypeBuildKey(typeToInject, name); Context.Policies.Clear <IBuildPlanPolicy>(buildKey); DependencyResolverTrackerPolicy.RemoveResolvers(Context.Policies, buildKey); }
/// <summary> /// API to configure the injection settings for a particular type/name pair. /// </summary> /// <param name="typeToInject">Type to configure.</param> /// <param name="name">Name of registration.</param> /// <param name="injectionMembers">Objects containing the details on which members to inject and how.</param> /// <returns>This extension object.</returns> public InjectedMembers ConfigureInjectionFor(Type typeToInject, string name, params InjectionMember[] injectionMembers) { foreach (InjectionMember member in injectionMembers) { member.AddPolicies(typeToInject, name, Context.Policies); } // Flush the build plan and current resolvers so that it will get rebuilt on next resolve. NamedTypeBuildKey buildKey = new NamedTypeBuildKey(typeToInject, name); Context.Policies.Clear <IBuildPlanPolicy>(buildKey); DependencyResolverTrackerPolicy.RemoveResolvers(Context.Policies, buildKey); return(this); }
public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies) { var serviceTypeBuildKey = new NamedTypeBuildKey(serviceType, name); policies.Clear <IBuildKeyMappingPolicy>(serviceTypeBuildKey); var buildKey = new NamedTypeBuildKey(implementationType, name); policies.Clear <IBuildKeyMappingPolicy>(buildKey); policies.Clear <IConstructorSelectorPolicy>(buildKey); policies.Clear <IBuildPlanCreatorPolicy>(buildKey); policies.Clear <IBuildPlanPolicy>(buildKey); policies.Clear <IMethodSelectorPolicy>(buildKey); policies.Clear <IPropertySelectorPolicy>(buildKey); policies.Clear <ILifetimeFactoryPolicy>(buildKey); policies.Clear <ILifetimePolicy>(buildKey); policies.Clear <IBuilderPolicy>(buildKey); DependencyResolverTrackerPolicy.RemoveResolvers(policies, buildKey); }