コード例 #1
0
        public IActionResult Get()
        {
            var productService = TransparentProxy <IProductService> .Create(new ProductManager(_memoryCache), _memoryCache);

            var result = productService.GetProductList();

            return(Ok(result));
        }
コード例 #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));
        }
コード例 #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);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: l5071134/AopSolutions
        private static void TestProxy()
        {
            ISimpleService svc = TransparentProxy.Create(new ProxyService());

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

            Console.WriteLine("执行结果为:" + rst);
        }
コード例 #5
0
        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();
        }
コード例 #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();
        }
コード例 #7
0
ファイル: Proxy.cs プロジェクト: 1244952898/CSharp
        public static void Show()
        {
            User user = new User()
            {
                Name = "Eleven", Password = "******"
            };

            //UserProcessor processor = new UserProcessor();

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

            userprocessor.RegUser(user);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: l5071134/AopSolutions
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #11
0
        public static IBankAccountService CreateTransparentProxy()
        {
            IBankAccountService bankAccountService = TransparentProxy <DummyBankAccountService, IBankAccountService> .CreateNew();

            return(bankAccountService);
        }
コード例 #12
0
 public ITravelService Create()
 {
     return(TransparentProxy <ITravelService> .Create(new TravelService()));
 }