C# unity interception by attribute

后端 未结 2 1863
遇见更好的自我
遇见更好的自我 2020-12-31 21:50

Is there a way on how to use interception by attribute in C# unity and keep the object registration code in XML file(like app.config)? If yes, can you provide me with code,

2条回答
  •  悲&欢浪女
    2020-12-31 22:23

    This is an old question but was really useful to me so I'll add the C# version of the unity configuration.

    container.Configure()
                .AddPolicy("LoggingPolicy")
                .AddMatchingRule(new CustomAttributeMatchingRule(typeof(MyInterceptionAttribute), false))
                .AddCallHandler();
    container.RegisterType(new Interceptor(), new InterceptionBehavior());
    

提交回复
热议问题