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

            var result = productService.GetProductList();

            return(Ok(result));
        }
Esempio 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));
        }
Esempio n. 3
0
        public static IBankAccountService CreateFilteredTransparentProxy()
        {
            var dynamicProxy = new TransparentProxy <DummyBankAccountService, IBankAccountService>();

            dynamicProxy.Filter = (m => !m.Name.StartsWith("Get"));
            IBankAccountService bankAccountService = (IBankAccountService)dynamicProxy.GetTransparentProxy();

            return(bankAccountService);
        }
Esempio n. 4
0
        private static void TestProxy()
        {
            ISimpleService svc = TransparentProxy.Create(new ProxyService());

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

            Console.WriteLine("执行结果为:" + rst);
        }
        static void Main(string[] args)
        {
            //transparent proxy class for intercepting
            var s = TransparentProxy <Student, IStudent> .GenerateProxy();

            var text = s.RegisterToLesson("Math");

            Console.WriteLine(text);
            Console.ReadKey();
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            // Servis örneğini oluşturuyoruz.
            var productService = TransparentProxy <ProductService, IProductService> .GenerateProxy();

            // Servis üzerinden GetProduct metotunu çağırıyoruz.
            var product = productService.GetProduct(1);

            Console.WriteLine("Id: {0}, Name: {1}, Price: {2}", product.Id, product.Name, product.Price);
            Console.ReadLine();
        }
Esempio n. 7
0
        public static void Show()
        {
            User user = new User()
            {
                Name = "Eleven", Password = "******"
            };

            //UserProcessor processor = new UserProcessor();

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

            userprocessor.RegUser(user);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        public TransparentProxy CreateProxy(HttpSocket clientSocket)
        {
            var proxy = new TransparentProxy(clientSocket, this);

            IPAddress ip    = GetIP();
            int       tries = 0;

            while (ip == null && tries < 5)
            {
                Thread.Sleep(500);

                ++tries;
                ip = GetIP();
            }

            if (ip != null)
            {
                proxy.InterfaceToBind = ip;
                return(proxy);
            }

            return(null);
        }
Esempio n. 11
0
        public static IBankAccountService CreateTransparentProxy()
        {
            IBankAccountService bankAccountService = TransparentProxy <DummyBankAccountService, IBankAccountService> .CreateNew();

            return(bankAccountService);
        }
 public ITravelService Create()
 {
     return(TransparentProxy <ITravelService> .Create(new TravelService()));
 }