Open
Description
提议,添加一个配置项,以便在创建代理类时可执行一些自定义操作,如:
services.ConfigureDynamicProxy({
c=>c.Interceptors.AddServiced<LogInterceptor>(
m=>m.DeclaringType.Name.EndsWith("AppService"));
c.OnGenerateProxy(context=>context.TypeBuilder.SetCustomAttribute(
CustomAttributeBuildeUtils.DefineCustomAttribute(typeof(DynamicallyAttribute)););
[NonAspect]
public interface IAspectConfiguration
{
AspectValidationHandlerCollection ValidationHandlers { get; }
InterceptorCollection Interceptors { get; }
NonAspectPredicateCollection NonAspectPredicates { get; }
bool ThrowAspectException { get; set; }
IAspectConfiguration OnGenerateProxy(Action<GenerateProxyContext> configureAction);
}
public sealed class GenerateProxyContext
{
public TypeBuilder TypeBuilder { get; init; }
public Type ServiceType { get; init; }
public Type ImplementType { get; init; }
}