Skip to content

Commit

Permalink
🚧 Update Samples of Interceptor.
Browse files Browse the repository at this point in the history
  • Loading branch information
catcherwong committed Mar 21, 2018
1 parent 061f2af commit 5cd4189
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
23 changes: 23 additions & 0 deletions sample/EasyCaching.Demo.Interceptor.AspectCore/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using EasyCaching.Demo.Interceptor.AspectCore.Services;
using EasyCaching.InMemory;
using EasyCaching.Interceptor.AspectCore;
using global::AspectCore.Configuration;
using global::AspectCore.Injector;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
Expand All @@ -26,7 +28,28 @@ public IServiceProvider ConfigureServices(IServiceCollection services)

services.AddMvc();

//1. all default
return services.ConfigureAspectCoreInterceptor();

//2. default and customize
//Action<IServiceContainer> action = x =>
//{
// x.AddType<IDateTimeService, DateTimeService>();
//};

//return services.ConfigureAspectCoreInterceptor(action);

//3. all customize
//Action<IServiceContainer> action = x =>
//{
// x.AddType<IDateTimeService, DateTimeService>();
// x.Configure(config =>
// {
// config.Interceptors.AddTyped<EasyCachingInterceptor>(method => typeof(Core.Internal.IEasyCaching).IsAssignableFrom(method.DeclaringType));
// });
//};

//return services.ConfigureAspectCoreInterceptor(action, true);
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
Expand Down
36 changes: 33 additions & 3 deletions sample/EasyCaching.Demo.Interceptor.Castle/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
namespace EasyCaching.Demo.Interceptor.Castle
{
{
using Autofac;
using Autofac.Extras.DynamicProxy;
using EasyCaching.InMemory;
using EasyCaching.Interceptor.Castle;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;

using System;
using System.Reflection;

public class Startup
{
public Startup(IConfiguration configuration)
Expand All @@ -25,7 +28,34 @@ public IServiceProvider ConfigureServices(IServiceCollection services)

services.AddDefaultInMemoryCache();

//1. all default
return services.ConfigureCastleInterceptor();

//2. default and customize
//Action<ContainerBuilder> action = x =>
//{
// x.RegisterType<DateTimeService>().As<IDateTimeService>();
//};

//return services.ConfigureCastleInterceptor(action);

//3. all customize
//Action<ContainerBuilder> action = x =>
//{
// x.RegisterType<DateTimeService>().As<IDateTimeService>();

// var assembly = Assembly.GetExecutingAssembly();
// x.RegisterType<EasyCachingInterceptor>();

// x.RegisterAssemblyTypes(assembly)
// .Where(type => typeof(Core.Internal.IEasyCaching).IsAssignableFrom(type) && !type.GetTypeInfo().IsAbstract)
// .AsImplementedInterfaces()
// .InstancePerLifetimeScope()
// .EnableInterfaceInterceptors()
// .InterceptedBy(typeof(EasyCachingInterceptor));
//};

//return services.ConfigureCastleInterceptor(action, true);
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
Expand Down

0 comments on commit 5cd4189

Please sign in to comment.