// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using DotNetGuru.AspectDNG.Joinpoints; public class Check { [AroundCall("* *::Divide(*)")] public static object MathCheck(MethodJoinPoint mjp) { object o = mjp[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"); } } return mjp.Proceed(); } }