Autofac を使用して、ある種の傍受を試みています。現在、いくつかの bll オブジェクトを構成しています。
updater.RegisterGeneric(typeof(BaseBll<>))
.AsImplementedInterfaces()
.InstancePerRequest()
.PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies)
.InterceptedBy(typeof(ActivityLogger));
updater.Register(c => new ActivityLogger());
クラスの 1 つに Interception 属性を設定します。
[Intercept(typeof(ActivityLogger))]
public class MyClassBll : BaseBll<TModel>, IMyClassBll
残念ながら、MyClassBll からいくつかのメソッドを呼び出すときに Intercept メソッドは呼び出されません。これがどのように修正されるかについてのアイデアがあれば、私に知らせてください。
今のところ、一時的な回避策を見つけました:
updater.RegisterType<MyClassBll>().As<IMyClassBll>().EnableInterfaceInterceptors();