C # - Custom Attributes
I want to log all calls to all methods of a class with a specific attribute. How can I do it?
This is what I have so far:
class ExecutionLogAttribute : Attribute
{
}
public class Human
{
private Int32 age;
[ExecutionLog]
public void HaveBirthday()
{
age++;
}
}
What is the best way to log all calls to HaveBirthday now?
+1
a source to share
1 answer
Simple answer: PostSharp . More complex: Spring.NET or custom AOP (that's what you want: aspect-oriented programming) using ContextBoundObject .
+9
a source to share