0
プロパティが設定されている場合にのみ、このメソッドが呼び出されます。なぜこれは機能しないのですか?このアスペクトで何が問題なのですか?
[DirtyTrackingAttribute(AttributeTargetElements =
PostSharp.Extensibility.MulticastTargets.Property)]
class Program
{
public static string Test { get; set; }
static void Main(string[] args)
{
TestIt();
Test = "foo";
Console.ReadKey();
}
private static void TestIt()
{
Console.WriteLine("Real method called");
}
}
[Serializable]
public class DirtyTrackingAttribute : OnMethodInvocationAspect
{
public override void OnInvocation(MethodInvocationEventArgs eventArgs)
{
Console.WriteLine("Property invoked");
eventArgs.Proceed();
}
}
いいえ、私はあなたが属性上で直接プロパティ名にフィルタをかけることができるのか分かりませんでした... 私はまた、PostSharpと一度遊んだことがあります。ここで私はプロパティへのアクセスを傍受したいのです。それをやりました: http://fgheysels.blogspot.com/2008/08/locking-system-with-aspect-oriented.html –