Considering the following code, is there a way to walk the object tree and determine all the methods with progress, their weight and an overall cost?
let's say I have a custom annotation:
public enum ProgressWeight
{
ExtraLight,
Light,
Medium,
Heavy,
ExtraHeavy
}
[AttributeUsage(AttributeTargets.Method)]
public class Progressable : Attribute
{
public ProgressWeight Weight { get; set; }
public Progressable(ProgressWeight weight)
{
this.Weight = weight;
}
}
And I want to implement it as such:
public class Sumathig
{
Foo CompositionObject;
[Progressable(ProgressWeight.Light)]
public void DoSomethingLight()
{
\\Do something that takes little time
}
[Progressable(ProgressWeight.ExtraHeavy)]
public void DoSomeIntesiveWork()
{
CompositionObject = new Foo();
CompositionObject.DoWork();
CompositionObject.DoMoreWork();
}
}
class Foo
{
[Progressable(ProgressWeight.Medium)]
public void DoWork()
{
\\Do some work
}
[Progressable(ProgressWeight.Heavy)]
public void DoSomeMoreWork()
{
\\Do more work
}
}