static H容器()
 {
     _IUnityContainer  = new UnityContainer();
     _Interception     = _IUnityContainer.AddNewExtension <Interception>().Configure <Interception>();
     _PolicyDefinition = _Interception.AddPolicy("MyPolicy");
     _PolicyDefinition.AddMatchingRule <AlwaysMatchingRule>();
     _PolicyDefinition.AddCallHandler <LoggerCallHandler>(new ContainerControlledLifetimeManager());
 }
Example #2
0
        public void AddInterceptor(string policy, IMatchingRule matchingRule, params Type[] classTypes)
        {
            Interception interception = uContainer.Configure <Interception>();

            foreach (Type classType in classTypes)
            {
                interception = interception.SetInterceptorFor(classType, new VirtualMethodInterceptor());
            }
            interception.AddPolicy(policy)
            .AddMatchingRule(matchingRule);
        }