I am working on a new kind of AOP Framework to answer the missing features of the existing AOP Framework. You can find my open source project here: NConcern.NET AOP Framework
One of the differences from the others is that you can develop your advice using System.Linq.Expression to avoid boxing / unpacking, reflection and hash type jumps. It's a little harder to develop with Expression for beginners, but easy for an advanced developer.
An example of a simple example of logging (in the console) without overwriting your company, reflection and boxing.
business: calculator
public class Calculator { public int Add(int a, int b) { return a + b; } }
your logging aspect, implemented with the linq expression, to describe how the Council should work.
public class Logging : IAspect { //this is not an advice, this method is called to produce advices public IEnumerable<IAdvice> Advise(MethodInfo method) { //generic presentation method var presentation = typeof(Presentation). GetMethod("Of"); //example log on exception //instance, arguments and exception are Expressions yield return Advice.Linq.After.Throwing((instance, arguments, exception) => { Expression.Call ( typeof(Console).GetMethod("WriteLine",...), Expression.Call ( typeof(string).GetMethod("Concat", new Type[] { typeof(string[]) }), Expression.NewArrayInit(typeof(string), arguments.Select(argument => argument.Type == typeof(string) ? argument : ...).ToArray()) ) ) } } }
source share