Exemplo n.º 1
0
        public IActionResult Get()
        {
            var productService = TransparentProxy <IProductService> .Create(new ProductManager(_memoryCache), _memoryCache);

            var result = productService.GetProductList();

            return(Ok(result));
        }
Exemplo n.º 2
0
        public IActionResult Post([FromBody] ProductItemDto productItemDto)
        {
            var productService = TransparentProxy <IProductService> .Create(new ProductManager(_memoryCache), _memoryCache);

            productService.AddProduct(productItemDto);

            return(Created(string.Empty, true));
        }
Exemplo n.º 3
0
        private static void TestProxy()
        {
            ISimpleService svc = TransparentProxy.Create(new ProxyService());

            svc.Execute();
            var rst = svc.GetResult();

            Console.WriteLine("执行结果为:" + rst);
        }
Exemplo n.º 4
0
        public static void Show()
        {
            User user = new User()
            {
                Name = "Eleven", Password = "******"
            };

            //UserProcessor processor = new UserProcessor();

            UserProcessor userprocessor = TransparentProxy.Create <UserProcessor>();

            userprocessor.RegUser(user);
        }
Exemplo n.º 5
0
        private static void TesAoptProxy()
        {
            ISimpleService _svc  = TransparentProxy.Create(new ProxyService());
            var            build = new ContainerBuilder();

            build.Register((c) => TransparentProxy.Create(new ProxyService())).As <ISimpleService>().InstancePerLifetimeScope();
            var container = build.Build();
            var svc       = container.Resolve <ISimpleService>();

            svc.Execute();
            var rst = svc.GetResult();

            Console.WriteLine("执行结果为:" + rst);
        }
Exemplo n.º 6
0
        public static void Show()
        {
            User user = new User()
            {
                Name = "Eleven", Password = "******"
            };

            UserProcessor processor = new UserProcessor();

            processor.RegUser(user);

            Console.WriteLine("*********************");
            UserProcessor userProcessor = TransparentProxy.Create <UserProcessor>();

            userProcessor.RegUser(user);
        }
 public ITravelService Create()
 {
     return(TransparentProxy <ITravelService> .Create(new TravelService()));
 }