Example #1
0
 public IEnumerable <IInterceptor> DetermineInterceptors(Type pluginType, Instance instance)
 {
     if (pluginType == typeof(IMyClass))
     {
         // DecoratorInterceptor is the simple case of wrapping one type with another
         // concrete type that takes the first as a dependency
         yield return(new FuncInterceptor <IMyClass>(i =>
                                                     (IMyClass)
                                                     DynamicProxyHelper.CreateInterfaceProxyWithTargetInterface(typeof(IMyClass), i)));
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            var container = new Container(_ =>
            {
                _.For <IMyClass>()
                .DecorateAllWith(
                    instance =>
                    (IMyClass)
                    DynamicProxyHelper.CreateInterfaceProxyWithTargetInterface(typeof(IMyClass), instance));
                _.For <IMyClass>().Use <MyClass>();
            });

            Read();
        }
Example #3
0
        public static void BootstrapStructureMap()
        {
            ObjectFactory.Initialize(initializer =>
            {
                initializer.AddRegistry <CommonsRegistry>();

                initializer.
                For <IServiceOne>().
                Use <ServiceOne>().
                EnrichWith(s => DynamicProxyHelper.CreateInterfaceProxyWithTargetInterface(typeof(IServiceOne), s));

                initializer.
                For <IServiceTwo>().
                Use <ServiceTwo>().
                EnrichWith(s => DynamicProxyHelper.CreateInterfaceProxyWithTargetInterface(typeof(IServiceTwo), s));
            });
        }