2011-12-19 32 views

Trả lời

17

Sử dụng phương pháp nhận thức, bạn có thể sử dụng đối tượng Args.Arguments để thay đổi giá trị thông qua phương pháp SetArgument.

[Serializable] 
public class MyAspect : MethodInterceptionAspect 
{ 
    public override void OnInvoke(MethodInterceptionArgs args) 
    { 
     string input = (string)args.Arguments[0]; 

     if (input.Equals("123")) 
     { 
      args.Arguments.SetArgument(0, " 456"); 
     } 

     args.Proceed(); 
    }  
} 
+4

+1 to PostSharp Guru;) –

Các vấn đề liên quan