views:

20

answers:

1

Do you know a pattern for method execution time measurement using EntLib's Unity and its interception mechanism?

A: 

You can create an ICallHandler (or very similar IInterceptionBehavior in Unity 2.0) implementation like below and add it to your object's execution timeline

public class MeasurementHandler : ICallHandler
{
  public IMethodReturn Invoke(IMethodInvocation input,
                               GetNextHandlerDelegate getNext)
  {
    StartTimer(); // implement it :)
    IMethodReturn msg = getNext()(input, getNext);  
    StopTimer(); // implement it :)
    return msg;
  }
}
A.