我有一个MethodInterceptionAspect
(PostSharp)的实现,
但是当我在覆盖OnInvoke
方法中时,它args.Method
是空的,我需要知道方法返回值类型,
有人知道吗?
[PSerializable]
public class PSHandleRequestAttribute : MethodInterceptionAspect
{
public PSHandleRequestAttribute(bool readOnly = true) : base()
{
ReadOnly = readOnly;
}
#region Properties
protected bool ReadOnly { get; set; }
#endregion Properties
#region Public Methods
public override void OnInvoke(MethodInterceptionArgs args)
{
var instance = args.Instance as IBusinessTransaction;
var method = args.Method;
if (instance.IsNull())
{
throw new Exception("Use PSHandleRequestAttribute only for IBusinessTransaction");
}
instance.OpenTransaction();
try
{
args.Proceed();
//base.OnInvoke(args);
instance.CommitTransaction();
return;
}
catch (Exception ex)
{
var errorMessage = instance.RollbackTransaction(ex);
return;
}
}
#endregion Public Methods
}