using System;
using System.Diagnostics;
using System.Reflection;

namespace Fody.MethodDecoratorDemo
{
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor)]
    public class InterceptorAttribute : Attribute, IMethodDecorator
    {
        public void OnEntry(MethodBase method)
        {
            Trace.WriteLine(string.Format("OnEntry: {0}", method.DeclaringType.FullName + "." + method.Name));
        }

        public void OnExit(MethodBase method)
        {
            Trace.WriteLine(string.Format("OnExit: {0}", method.DeclaringType.FullName + "." + method.Name));
        }

        public void OnException(MethodBase method, Exception exception)
        {
            Trace.WriteLine(string.Format("OnException: {0} - {1}: {2}", method.DeclaringType.FullName + "." + method.Name, exception.GetType(), exception.Message));
        }
    }
}
