コード例 #1
0
ファイル: ProxyHelper.cs プロジェクト: tianfengs/AbpPractice
 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)));
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: tianfengs/AbpPractice
        static void Main(string[] args)
        {
            var container = new Container(_ =>
            {
                _.For <IMyClass>()
                .DecorateAllWith(
                    instance =>
                    (IMyClass)
                    DynamicProxyHelper.CreateInterfaceProxyWithTargetInterface(typeof(IMyClass), instance));
                _.For <IMyClass>().Use <MyClass>();
            });

            Read();
        }
コード例 #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));
            });
        }