I have an OnMethodBoundary aspect I created to keep track of progress events in a template method. One of the things that would be useful to know in terms of the overall progress is the number of progress steps that are required by my process before it finishes, i.e. the number of methods tagged with my [AffectsProgress] attribute.
Rather than hard coding it and having to maintain that as I add and remove methods, I've tried using System.Reflection to determine that with code like the following (there were many variants I tried):
typeof (MyModuleWithProgressSteps)
.GetMethods()
.SelectMany(x => x.CustomAttributes.Where(attribute => attribute.AttributeType == typeof (AffectsProgress)))
However, even though I was able to see other attributes when I removed the Where clause, I was unable to find any PostSharp aspects. My naive guess is that PostSharp aspects that interfere with the call stack upon execution aren't actually traditional method attributes and so the System.Reflection library doesn't see them.
Does anyone know of a way I could get what I'm looking for either with System.Reflection or with PostSharp itself? I came across ReflectionSearch and IAspectRepositoryService which require the Ultimate edition but I'm not sure if those are sufficient or not.
Aucun commentaire:
Enregistrer un commentaire