Skip to content

suggest:创建代理类类型时执行自定义操作。 #238

Open
@wzd24

Description

@wzd24

提议,添加一个配置项,以便在创建代理类时可执行一些自定义操作,如:

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; }

    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions