3
Castle DynamicProxy로 속성을 가로채는 더 좋은 방법에 대한 제안이 있습니까? 내 IInterceptor에서 다음캐슬 윈저 IInterceptor로 가로 채기 속성
public static PropertyInfo GetProperty(this MethodInfo method)
{
bool takesArg = method.GetParameters().Length == 1;
bool hasReturn = method.ReturnType != typeof(void);
if (takesArg == hasReturn) return null;
if (takesArg)
{
return method.DeclaringType.GetProperties()
.Where(prop => prop.GetSetMethod() == method).FirstOrDefault();
}
else
{
return method.DeclaringType.GetProperties()
.Where(prop => prop.GetGetMethod() == method).FirstOrDefault();
}
}
:
#region IInterceptor Members
public void Intercept(IInvocation invocation)
{
bool doSomething = invocation.Method.GetProperty().GetCustomAttributes(true).OfType<SomeAttribute>().Count() > 0;
}
#endregion
덕분에 내가 무엇이며, 특별한 방법, 나는 차단있어 PropertyInfo이 필요하지만, 그것은 IInvocation에 직접 아니다.