public void Find_CompoundInterceptor_For_A_Type_On_The_First_Pass()
 {
     Assert.AreEqual(new TypeInterceptor[] { _interceptor1, _interceptor3, _interceptor4 },
                     _library.FindInterceptor(typeof(string)).Interceptors);
     Assert.AreEqual(new TypeInterceptor[] { _interceptor2, _interceptor4 },
                     _library.FindInterceptor(typeof(double)).Interceptors);
 }
        public void Import_from_gets_all_interceptors_and_resets_the_type_filter()
        {
            var sourceLibrary = new InterceptorLibrary();

            sourceLibrary.AddInterceptor(new MockTypeInterceptor(typeof(string)));
            sourceLibrary.FindInterceptor(typeof(string));

            var destinationLibrary = new InterceptorLibrary();

            destinationLibrary.AddInterceptor(new MockTypeInterceptor(typeof(string)));

            destinationLibrary.ImportFrom(sourceLibrary);

            InstanceInterceptor[] interceptors = destinationLibrary.FindInterceptors(typeof(string));
            Assert.AreEqual(2, interceptors.Length);
        }
예제 #3
0
        public virtual object ApplyInterception(Type pluginType, object actualValue, BuildSession session,
                                                Instance instance)
        {
            if (actualValue == null)
            {
                return(null);
            }

            try
            {
                return(_library.FindInterceptor(actualValue.GetType()).Process(actualValue, session));
            }
            catch (Exception e)
            {
                throw new StructureMapException(308, e, instance.Name, actualValue.GetType());
            }
        }