コード例 #1
0
        private static ActivityScope AddActivityScope(ActivityContextState activityContextState, object userState, ActivityType activityType, ActivityEventArgs eventArgs, LocalizedString exceptionString)
        {
            bool          flag          = false;
            bool          flag2         = false;
            ActivityScope activityScope = null;

            if (ActivityContext.IsStarted)
            {
                try
                {
                    throw new ActivityContextException(exceptionString);
                }
                catch (ActivityContextException)
                {
                    flag2 = true;
                }
                if (SingleContext.Singleton.CheckId())
                {
                    ActivityScopeImpl activityScopeImpl = (ActivityScopeImpl)ActivityContext.GetCurrentActivityScope();
                    if (activityScopeImpl != null)
                    {
                        return(new ActivityScope(activityScopeImpl));
                    }
                }
            }
            if (SingleContext.Singleton.LocalId != null && !flag2)
            {
                try
                {
                    throw new ActivityContextException(DiagnosticsResources.ExceptionActivityContextMustBeCleared(DebugContext.GetDebugInfo()));
                }
                catch (ActivityContextException)
                {
                }
            }
            ActivityScope result;

            try
            {
                activityScope              = ActivityScopeImpl.AddActivityScope(activityContextState);
                activityScope.UserState    = userState;
                activityScope.ActivityType = activityType;
                ActivityContext.RaiseEvent(activityScope.ActivityScopeImpl, eventArgs);
                ExTraceGlobals.ActivityContextTracer.TraceDebug <Guid, bool>((long)activityScope.LocalId.GetHashCode(), "ActivityContext.AddActivityScope - ActivityId {0}, (activityContextState != null) = {1}", activityScope.ActivityId, activityContextState != null);
                flag   = true;
                result = activityScope;
            }
            finally
            {
                if (!flag)
                {
                    if (activityScope != null)
                    {
                        activityScope.Dispose();
                    }
                    ActivityContext.ClearThreadScope();
                }
            }
            return(result);
        }
コード例 #2
0
        public ActivityContextState Suspend()
        {
            Func <string, LocalizedString> func = (string debugInfo) => DiagnosticsResources.ExceptionMustStartBeforeSuspend(debugInfo);

            if (this.status == 2)
            {
                try
                {
                    throw new ActivityContextException(func(DebugContext.GetDebugInfo()));
                }
                catch (ActivityContextException)
                {
                }
                return(new ActivityContextState(this, this.metadata));
            }
            this.TransitionToFinalStatus(ActivityContextStatus.ActivitySuspended, ActivityContext.OnSuspendEventArgs);
            return(new ActivityContextState(this, this.metadata));
        }
コード例 #3
0
        internal static ActivityScope DeserializeFrom(HttpRequest httpRequest, object userState = null)
        {
            ActivityContextState activityContextState = ActivityContextState.DeserializeFrom(httpRequest);

            return(ActivityContext.AddActivityScope(activityContextState, userState, (activityContextState != null) ? activityContextState.ActivityType : ActivityType.Request, ActivityContext.OnStartEventArgs, DiagnosticsResources.ExceptionScopeAlreadyExists(DebugContext.GetDebugInfo())));
        }
コード例 #4
0
 public static ActivityScope Resume(ActivityContextState activityContextState, object userState = null)
 {
     if (activityContextState == null)
     {
         try
         {
             throw new ArgumentNullException("activityContextState was null");
         }
         catch (ArgumentException)
         {
         }
     }
     return(ActivityContext.AddActivityScope(activityContextState, userState, (activityContextState != null) ? activityContextState.ActivityType : ActivityType.Request, ActivityContext.OnResumeEventArgs, DiagnosticsResources.ExceptionScopeAlreadyExists(DebugContext.GetDebugInfo())));
 }
コード例 #5
0
 public static ActivityScope Start(object userState, ActivityType activityType)
 {
     return(ActivityContext.AddActivityScope(null, userState, activityType, ActivityContext.OnStartEventArgs, DiagnosticsResources.ExceptionStartInvokedTwice(DebugContext.GetDebugInfo())));
 }