Example #1
0
        public void Proxy()
        {
            ICommandHandler <MyCommand> commandHandler
                = LoggingProxy <ICommandHandler <MyCommand> > .Create(new MyCommandHandler());

            commandHandler.Handle(new MyCommand());

            IFoo f = LoggingProxy <IFoo> .Create(new Foo());

            f.Add();
            f.Delete();
        }
        public void InterceptorTest()
        {
            IServiceCollection services = new ServiceCollection();

            services.AddTransient <IFoo, Foo>()
            .AddSingleton(new FooConfig {
                Name = "redis"
            });
            IServiceProvider serviceProvider = services.BuildCastleDynamicProxyProvider();
            IFoo             foo             = serviceProvider.GetService <IFoo>();
            bool             addFlag         = foo.Add(new FooModel {
                Id = 1, Name = "test", Date = DateTime.Now
            });

            foo.Delete(1);
            FooModel fooModel = foo.Get(1);
        }
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    IFoo foo     = app.ApplicationServices.GetService <IFoo>();
                    bool addFlag = foo.Add(new FooModel {
                        Id = 1, Name = "test", Date = DateTime.Now
                    });
                    foo.Delete(1);
                    FooModel fooModel = foo.Get(1);
                    await context.Response.WriteAsync("Hello World!");
                });
            });
        }
Example #4
0
 public async void Delete()
 {
     await foo.Delete(11);
 }
Example #5
0
 public Task Delete(int id) => foo.Delete(id);