클래스 속성을 기반으로 등록 된 클래스에 인터셉터를 추가하는 기능을 만들려고합니다. 이 내 시설입니다 :성 윈저 시설 내에서 클래스 프록시 만들기
public class MyFacility : AbstractFacility
{
protected override void Init()
{
this.Kernel.ComponentRegistered += (s, h) =>
{
if (h.ComponentModel.Implementation.GetCustomAttributes(typeof(MyAttribute), false).Length > 0)
{
h.ComponentModel.Interceptors.Add(InterceptorReference.ForType<MyInterceptor>());
}
}
}
}
하지만 클래스 메소드에 this
키워드를 사용할 때이 방법, 그것은 대상 클래스가 아닌 프록시 클래스를 의미하고 이것이 내가 제대로 작동하지 않습니다 사용하는 일부 프레임 워크를 만드는 .
ProxyGenerator.CreateClassProxy<MyClass>()
메서드로 생성 된 프록시와 동일한 프록시를 생성해야합니다.
어떻게하면됩니까?
더 많은 코드를 표시 할 수 있습니까? 인터페이스 또는 클래스를 등록하는 구성 요소입니까? – svick
등록 할 구성 요소가 인터페이스입니다. Thi는 윈저 설치입니다. _wc = new WindsorContainer(); _wc.AddFacility(); _wc.Register ( ) Component.For () ); _wc. 등록자 ( ) 구성 요소. (). 구현 됨 () ); –
Gigitsu