// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using PostSharp.Laos; [Serializable] public class Check : OnMethodBoundaryAspect { public override void OnEntry(MethodExecutionEventArgs ctx) { object o = ctx.GetReadOnlyArgumentArray()[1]; if(o is int) { if((int)o == 0) { Console.WriteLine("About to divide by zero"); } } if(o is double) { if((double)o == 0) { Console.WriteLine("About to divide by zero"); } } } }