internal static ActivityScope AddActivityScope(ActivityContextState activityContextState)
        {
            Guid          guid = Guid.NewGuid();
            ActivityScope result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                try
                {
                    ActivityScopeImpl.scopeCacheLock.EnterWriteLock();
                    ActivityScopeImpl activityScopeImpl = new ActivityScopeImpl(guid);
                    disposeGuard.Add <ActivityScopeImpl>(activityScopeImpl);
                    ActivityScopeImpl.scopeCache.Add(guid, activityScopeImpl);
                    ActivityScope activityScope = new ActivityScope(activityScopeImpl);
                    disposeGuard.Add <ActivityScope>(activityScope);
                    activityScopeImpl.UpdateFromState(activityContextState);
                    SingleContext.Singleton.LocalId = new Guid?(guid);
                    SingleContext.Singleton.SetId();
                    disposeGuard.Success();
                    result = activityScope;
                }
                finally
                {
                    try
                    {
                        ActivityScopeImpl.scopeCacheLock.ExitWriteLock();
                    }
                    catch (SynchronizationLockException)
                    {
                    }
                }
            }
            return(result);
        }
Example #2
0
        internal static void UpdateActivityScopeRequestIdFromUrl(string httpUrl)
        {
            if (string.IsNullOrWhiteSpace(httpUrl))
            {
                return;
            }
            Uri uri = new Uri(httpUrl);
            NameValueCollection urlProperties = LoggerHelper.GetUrlProperties(uri);
            string text = urlProperties["RequestId48CD6591-0506-4D6E-9131-797489A3260F"];
            Guid   guid;

            if (text == null || !Guid.TryParse(text, out guid))
            {
                return;
            }
            ActivityScopeImpl activityScopeImpl = ActivityContext.GetCurrentActivityScope() as ActivityScopeImpl;

            if (activityScopeImpl == null)
            {
                return;
            }
            if (activityScopeImpl.ActivityId == guid)
            {
                return;
            }
            ActivityContextState state = new ActivityContextState(new Guid?(guid), LoggerHelper.EmptyConcurrentDic);

            activityScopeImpl.UpdateFromState(state);
        }
        public void UpdateFromMessage(HttpRequestBase httpRequestBase)
        {
            ActivityContextState activityContextState = ActivityContextState.DeserializeFrom(httpRequestBase);

            if (activityContextState != null)
            {
                this.UpdateFromState(activityContextState);
            }
        }
        public void UpdateFromMessage(HttpRequestMessageProperty wcfMessage)
        {
            ActivityContextState activityContextState = ActivityContextState.DeserializeFrom(wcfMessage);

            if (activityContextState != null)
            {
                this.UpdateFromState(activityContextState);
            }
        }
        public void UpdateFromMessage(OperationContext wcfOperationContext)
        {
            ActivityContextState activityContextState = ActivityContextState.DeserializeFrom(wcfOperationContext);

            if (activityContextState != null)
            {
                this.UpdateFromState(activityContextState);
            }
        }
Example #6
0
 internal RfriContext(ClientSecurityContext clientSecurityContext, string userDomain, string clientAddress, string serverAddress, string protocolSequence, string authenticationService, bool encrypted, bool isAnonymous, Guid requestId = default(Guid))
 {
     this.ContextHandle         = NspiContext.GetNextContextHandle();
     this.disposeTracker        = ((IDisposeTrackable)this).GetDisposeTracker();
     this.clientSecurityContext = clientSecurityContext;
     this.userDomain            = userDomain;
     this.encrypted             = encrypted;
     this.isAnonymous           = isAnonymous;
     this.protocolSequence      = protocolSequence;
     this.protocolLogSession    = ProtocolLog.CreateSession(this.ContextHandle, clientAddress, serverAddress, protocolSequence);
     this.ProtocolLogSession[ProtocolLog.Field.Authentication] = authenticationService;
     if (requestId != Guid.Empty)
     {
         ActivityContextState activityContextState = new ActivityContextState(new Guid?(requestId), new ConcurrentDictionary <Enum, object>());
         ActivityContext.ClearThreadScope();
         this.scope = ActivityContext.Resume(activityContextState, null);
     }
 }
 internal void UpdateFromState(ActivityContextState state)
 {
     if (state != null)
     {
         if (state.ActivityId != null)
         {
             this.ActivityId   = state.ActivityId.Value;
             this.ActivityType = state.ActivityType;
         }
         if (state.Properties != null)
         {
             foreach (KeyValuePair <Enum, object> keyValuePair in state.Properties)
             {
                 this.SetPropertyObject(keyValuePair.Key, keyValuePair.Value);
             }
         }
         DebugContext.UpdateFrom(this);
     }
 }
 internal string GetMinimalSerializedScope()
 {
     return(ActivityContextState.GetMinimalSerializedScope(this.ActivityId));
 }