public IActionResult Get() { var productService = TransparentProxy <IProductService> .Create(new ProductManager(_memoryCache), _memoryCache); var result = productService.GetProductList(); return(Ok(result)); }
public IActionResult Post([FromBody] ProductItemDto productItemDto) { var productService = TransparentProxy <IProductService> .Create(new ProductManager(_memoryCache), _memoryCache); productService.AddProduct(productItemDto); return(Created(string.Empty, true)); }
public static IBankAccountService CreateFilteredTransparentProxy() { var dynamicProxy = new TransparentProxy <DummyBankAccountService, IBankAccountService>(); dynamicProxy.Filter = (m => !m.Name.StartsWith("Get")); IBankAccountService bankAccountService = (IBankAccountService)dynamicProxy.GetTransparentProxy(); return(bankAccountService); }
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(); }
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(); }
public static void Show() { User user = new User() { Name = "Eleven", Password = "******" }; //UserProcessor processor = new UserProcessor(); UserProcessor userprocessor = TransparentProxy.Create <UserProcessor>(); userprocessor.RegUser(user); }
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); }
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 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); }
public static IBankAccountService CreateTransparentProxy() { IBankAccountService bankAccountService = TransparentProxy <DummyBankAccountService, IBankAccountService> .CreateNew(); return(bankAccountService); }
public ITravelService Create() { return(TransparentProxy <ITravelService> .Create(new TravelService())); }