I have an implementation of MethodInterceptionAspect
(PostSharp)
but when I in the override OnInvoke
method, the args.Method
is null,
I need to know the method return value type,
anyone know about?
[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
}