i'm done an attribute in c# that goes on methods, i simply want that when method (with the attribute) starts, this does start a stopwatch that will it close at the end of method called, the attribute at compile time should verify if another attribute is setted on the class, because at run time when stopwatch will stopped, the elapsed time should be writed in a property of attribute of the class, or otherwise passed him. How can to do this?
[AttributeUsage(AttributeTargets.Method)]
public class WatchingAttribute : Attribute
{
WatchingAttribute([CallerMemberName] string propertyName = null, etc, etc...)
{
/*verify that Registry is an attribute of class */
/*before ending write data on Registry*/
}
}
/*this should be contain data of execution of methods*/
[AttributeUsage(AttributeTargets.Class)]
public class Registry : Attribute
{
/*varible for manage registred data:
*..
*..
*/
Registry()
{
}
}
Can there be threading problems?
Aucun commentaire:
Enregistrer un commentaire