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);
        }
    }
}

 

相关文章:

  • 2022-03-01
  • 2021-07-28
  • 2021-12-27
  • 2021-11-11
  • 2022-01-02
猜你喜欢
  • 2021-07-08
  • 2021-05-16
  • 2022-12-23
  • 2021-05-30
  • 2021-06-14
相关资源
相似解决方案