Exemplo n.º 1
0
 /// <summary>
 /// Adds a binding pair.
 /// </summary>
 /// <param name="aspectRegistration">The interceptor.</param>
 /// <param name="attributeType">Type of the attribute.</param>
 internal void BindInterceptor(AspectRegistration aspectRegistration, Type attributeType)
 {
     aspectRegistration.TargetAttributeType = attributeType;
     if (!_interceptorRegistrations.Contains(aspectRegistration))
     {
         _interceptorRegistrations.Add(aspectRegistration);
     }
 }
        /// <summary>
        /// Creates instance of <paramref name="aspectRegistration">interceptor</paramref> for given interceptor registration.
        /// </summary>
        /// <param name="aspectRegistration">Registration of interceptor, is built on aspect configuration build step</param>
        /// <returns></returns>
        public IAttributeInterceptor Create(AspectRegistration aspectRegistration)
        {
            // Assume interceptor type implements IAttributeInterceptor contract.
            // This rule is enforced on aspect configuration build step
            var interceptor = (IAttributeInterceptor)_container.GetInstance(aspectRegistration.InterceptorType);

            // reassign target attribute and order properties from interception registration to actual interceptor instance
            interceptor.TargetAttribute = aspectRegistration.TargetAttributeType;
            interceptor.Order           = aspectRegistration.Order;
            return(interceptor);
        }
        /// <summary>
        /// Creates instance of <paramref name="aspectRegistration">interceptor</paramref> for given interceptor registration
        /// </summary>
        /// <param name="aspectRegistration">Registration of interceptor, is built on aspect configuration build step</param>
        /// <returns></returns>
        public IAttributeInterceptor Create(AspectRegistration aspectRegistration)
        {
            // Assume interceptor type implements IAttributeInterceptor contract and has parameterless constructor.
            // This rule is enforced on aspect configuration build step
            var interceptor = (IAttributeInterceptor)Activator.CreateInstance(aspectRegistration.InterceptorType);

            // reassign target attribute and order properties from interception registration to actual interceptor instance
            interceptor.TargetAttribute = aspectRegistration.TargetAttributeType;
            interceptor.Order = aspectRegistration.Order;

            return interceptor;
        }
Exemplo n.º 4
0
        private IInterceptorCreationStrategy ResolveHowToCreateInterceptor(AspectRegistration aspectRegistration)
        {
            IInterceptorCreationStrategy strategy;

            if (Container == null)
            {
                // when container is not specified, always use InstantiateInterceptorDirectlyCreationStrategy
                // without considering AspectRegistration.KeptInContainer setting
                strategy = new InstantiateInterceptorDirectlyCreationStrategy();
            }
            else if (aspectRegistration.KeptInContainer)
            {
                strategy = new ResolveInterceptorFromContainerCreationStrategy(Container);
            }
            else
            {
                strategy = new InstantiateInterceptorDirectlyCreationStrategy();
            }
            return(strategy);
        }
Exemplo n.º 5
0
 private IInterceptorCreationStrategy ResolveHowToCreateInterceptor(AspectRegistration aspectRegistration)
 {
     IInterceptorCreationStrategy strategy;
     if(Container == null)
     {
         // when container is not specified, always use InstantiateInterceptorDirectlyCreationStrategy
         // without considering AspectRegistration.KeptInContainer setting
         strategy = new InstantiateInterceptorDirectlyCreationStrategy();
     }
     else if (aspectRegistration.KeptInContainer)
     {
         strategy = new ResolveInterceptorFromContainerCreationStrategy(Container);
     }
     else
     {
         strategy = new InstantiateInterceptorDirectlyCreationStrategy();
     }
     return strategy;
 }