/// <summary>
/// Constructor used to initialize the class
/// </summary>
/// <param name="traceSource">The source that we are tracing through as part of this scope</param>
/// <param name="activityName">The name of the activity that this scope represents</param>
public TraceTransferScope(TraceSource traceSource, string activityName)
{
if (traceSource == null)
{
throw new ArgumentNullException("traceSource");
}
if (string.IsNullOrEmpty(activityName))
{
throw new ArgumentNullException("activityName");
}
_traceSource = traceSource;
_oldActivityId = Trace.CorrelationManager.ActivityId;
_activityName = activityName;
_newActivityId = Guid.NewGuid();
if (_oldActivityId != Guid.Empty)
{
// transfer to activity
_traceSource.TraceTransfer(0, string.Format(CultureInfo.CurrentCulture, "TRANSFER ==> {0} ===", _activityName), _newActivityId);
}
Trace.CorrelationManager.ActivityId = _newActivityId;
_traceSource.Start(_activityName);
}