/// <summary> /// Add policies to the <paramref name="policies"/> to configure the container with /// an appropriate <see cref="IInstanceInterceptionPolicy"/> /// </summary> /// <param name="serviceType">Type of the interface being registered. This parameter is /// ignored by this class.</param> /// <param name="implementationType">Type to register.</param> /// <param name="name">Name used to resolve the type object.</param> /// <param name="policies">Policy list to add policies to.</param> public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies) { var key = new NamedTypeBuildKey(implementationType); policies.Set<IInstanceInterceptionPolicy>(new FixedInstanceInterceptionPolicy(Interceptor), key); var piabInjectionMember = new InterceptionBehavior<PolicyInjectionBehavior>(); piabInjectionMember.AddPolicies(serviceType, implementationType, name, policies); }
private void OnRegister(object sender, RegisterEventArgs e) { if (ShouldIntercept(e)) { var container = sender as IUnityContainer; var i = new Interceptor<InterfaceInterceptor>(); i.AddPolicies(e.TypeFrom, e.TypeTo, e.Name, Context.Policies); _interceptionBehaviors.ForEach( (b) => { var interfaceBehavior = new InterceptionBehavior(b); interfaceBehavior.AddPolicies(e.TypeFrom, e.TypeTo, e.Name, Context.Policies); }); } }