Exemplo n.º 1
0
        public void Add_TypeList()
        {
            var list = new ServiceInterceptorList();

            list.GetInterceptors(typeof(IProxiedService)).ShouldBeEmpty();
            Should.Throw <ArgumentNullException>(() => list.Add(typeof(IProxiedService), (Type)null));
            Should.Throw <ArgumentNullException>(() => list.Add(null, (ITypeList <IInterceptor>)null));
            Should.Throw <ArgumentNullException>(() => list.Add(null, new TypeList <IInterceptor>()));
            list.Add(typeof(IProxiedService), new TypeList <IInterceptor>());
            list.GetInterceptors(typeof(IProxiedService)).ShouldBeEmpty();
            list.Add(typeof(IProxiedService), new TypeList <IInterceptor>().Action(l => l.Add <TestInterceptor>()));
            list.GetInterceptors(typeof(IProxiedService)).ShouldHaveSingleItem().ShouldBe(typeof(TestInterceptor));
        }
Exemplo n.º 2
0
        private static IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> InvokeRegistrationActions <TLimit, TActivatorData, TRegistrationStyle>(this IRegistrationBuilder <TLimit, TActivatorData, TRegistrationStyle> registrationBuilder, ServiceInterceptorList serviceInterceptorList, Type serviceType, Type implementationType)
            where TActivatorData : ReflectionActivatorData
        {
            var interceptors = serviceInterceptorList.GetInterceptors(serviceType).Concat(serviceInterceptorList.GetInterceptors(implementationType));

            if (interceptors.Any())
            {
                registrationBuilder = registrationBuilder.AddInterceptors(
                    serviceType,
                    interceptors
                    );
            }

            return(registrationBuilder);
        }