I am using log4net, and we have a lot of code in this code:
< Code> Public Class Fu {Private Static Readonly Illog Log = Log Manager. Get Loger (typef (foo)); ....}
One downside is that it means that we are sticking to this 10-word block altogether, and every now and then changing a class name Forgets in It also mentions this alternative possibility, which has even more vocabulary:
public class Fu {Ilog Log = Log Manager for Private Static reading. GetLoggers (System. Reflections. Mathbabes. Gate CrurmentMip);); ...}
Is it possible to write a decorator to define it? I would really like to say:
[LogMe] // or perhaps: [LogMe ("log")] public square fu {...}
< P> I have done similar work in other languages, but have never been statistically compiled like C #. Can I define class members from the decorator? Edit : Heh. I am a Lisp programmer. I appreciate the suggestions for switching languages, but in fact, if I was going to switch languages for better metaprogramming capabilities, then I would like to talk about it instead of halfway Wanted to go all the way. Unfortunately, the use of a different language is not an option on this project.
This is absolutely an assignment for AOP - aspect-based programming. Look, this one. AOP Framework, it will allow you to do the same way you want.
It works by modifying (or weaving) IL code in the post-compilation, and adding the logging aspect to the decorated method.
Edit: It seems that the post town is just a business product if you are looking for an open source (free) solution, then I suggest.
Comments
Post a Comment