using System; using System.Collections.Generic; using System.Linq; using System.Text; using PostSharp.Laos; using PostSharp; namespace PostSharpApp { [MyTrace(AttributeTargetMembers="Test*")] class Program { static void Main(string[] args) { Test1(); Test2(); Foo(); Console.ReadLine(); } static void Test1() { Console.WriteLine("Hello world! 1"); } static void Test2() { Console.WriteLine("Hello world! 2"); } static void Foo() { Console.WriteLine("Hello world! 3"); } } [Serializable] class MyTrace : OnMethodBoundaryAspect { public override void OnEntry(MethodExecutionEventArgs eventArgs) { Console.WriteLine("Entering {0}", eventArgs.Method); } public override void OnExit(MethodExecutionEventArgs eventArgs) { Console.WriteLine("Exiting {0}", eventArgs.Method); } } }
时间: 2024-10-25 10:20:52