public void Action(IProxyConventionalActionContext context) { var predicate = context.TypePredicate.Compile(); var interceptors = context.Services.GetSingletonInstanceOrAdd(s => new ServiceInterceptorList()); context.Interceptors.ForEach(t => context.Services.AddTransient(t)); context.Types.Where(predicate).ForEach(t => interceptors.Add(t, context.Interceptors)); }
public void Action(IProxyConventionalActionContext context) { var predicate = context.TypePredicate.Compile(); context.Interceptors.ForEach(t => { context.Services.TryAddTransient(t); var interceptorType = typeof(AspectCoreInterceptorAdapter <>).MakeGenericType(t); _ = context.Services.ConfigureDynamicProxy(c => c.Interceptors.AddServiced(interceptorType, m => predicate(m.DeclaringType))); }); }