PostSharp에 처음 오신 것을 환영합니다. - 지금 NuGet 버전을 시험하고 있으며, agrs.Instance 값이 null 인 AuthoriseAttribute OnEntry 메소드에서 wny를 이해하려고합니다. 예를 들어 객체의 값에 의존하는 저작물을 구현하려고합니다. 보관 처리 된 고객의 크레딧 한도를 높일 수 없습니다. 규칙과 관련된 다른 클래스 내에서 규칙을 구현하고 있습니다.Postsharp Newbie - 왜 args.Instance null입니까?
public class Program
{
static void Main(string[] args)
{
var c = new Customer();
c.RaiseCreditLimit(100000);
c.Error(00);
}
}
public class Customer
{
[AuthorizeActivity]
public void RaiseCreditLimit(int newValue)
{
}
[AuthorizeActivity]
public void Error(int newValue)
{
}
}
[Serializable]
public class AuthorizeActivityAttribute : OnMethodBoundaryAspect
{
public override void OnEntry(MethodExecutionArgs args)
{
//
//Why is args.Instance null???????????
//
if (args.Method.Name == "RaiseCreditLimit")
{
Debug.WriteLine(args.Method.Name + " started");
}
else
{
throw new Exception("Crap");
}
}
public override void OnExit(MethodExecutionArgs args)
{
Debug.WriteLine(args.Method.Name + " finished");
}
}
이 알아 낸 당신이나요 코드를 최적화 할 않는 그 밖의 무엇을보고이 문서를 체크 아웃? –