Endjin.Assembly.ChangeDetection.Infrastructure.Tracer.Dispose C# (CSharp) Method

Dispose() public method

Generate a leaving method trace. Normally called at the end of an using statement.
When the method is left with an exception and Exception tracing is enabled it will trace this exception.
public Dispose ( ) : void
return void
        public void Dispose()
        {
            if (TracerConfig.Instance.IsEnabled(this.myType, MessageTypes.Exception, this.myLevel))
            {
                // only print exception warning when we did not have an exception on the thread stack
                // when we did enter this method. Otherwise we would print a warning while we entered and left a method while
                // executing a catch handler altough in our called methods nothing has happened.
                var currentException = ExceptionHelper.CurrentException;
                if (currentException != null && ReferenceEquals(myLastPrintedException, currentException) == false)
                {
                    myLastPrintedException = currentException;
                    TraceMsg(MsgTypeException, this.TypeMethodName, DateTime.Now, "Exception thrown: {0}", currentException);
                }
            }

            if (TracerConfig.Instance.IsEnabled(this.myType, MessageTypes.InOut, this.myLevel))
            {
                var now = DateTime.Now;
                TraceMsg(MsgTypeOut, this.TypeMethodName, now, "Duration {0}", this.FormatDuration(now.Ticks - this.myEnterTime.Ticks));
            }
        }