Example #1
0
        /// <summary>
        /// End the call context
        /// </summary>
        /// <param name="threadId">id of the thread on which to end the context</param>
        /// <param name="nodeId">id of the context node</param>
        public void EndCallContext(int?threadId = null, Guid?nodeId = null)
        {
            OperationContext context = OperationContext.Current;

            if (context != null)
            {
                Stack <Dictionary <string, object> > dataStack;
                if (s_contextData.TryGetValue(context, out dataStack) && dataStack.Count > 0)
                {
                    dataStack.Pop();
                    if (dataStack.Count == 0)
                    {
                        s_contextData.TryRemove(context, out dataStack);

                        ConcurrentDictionary <string, object> _;
                        s_sharedContextData.TryRemove(context, out _);
                    }

                    return;
                }
                else
                {
                    throw new InvalidOperationException("Attempting to end an OperationCallContext that has not been started");
                }
            }

            m_backupCallContext.EndCallContext(threadId, nodeId);
        }
		public void TestCleanup()
		{
			ICallContext context = CallContextManagerInstance.CallContextOverride;

			ICallContext existingContext = context.ExistingCallContext();
			Correlation.CorrelationEnd();
			context.EndCallContext();
		}
Example #3
0
        /// <summary>
        /// End a request
        /// </summary>
        private void EndRequest()
        {
            ICallContext context = CallContextManagerInstance.CallContextOverride;

            ICallContext existingContext = context.ExistingCallContext();

            Correlation.CorrelationEnd();
            context.EndCallContext();
        }
Example #4
0
        /// <summary>
        /// End the call context
        /// </summary>
        /// <param name="threadId">id of the thread on which to end the context</param>
        /// <param name="nodeId">id of the context node</param>
        public void EndCallContext(int?threadId = null, Guid?nodeId = null)
        {
            HttpContext current = HttpContextWrapper.Current;

            if (current != null)
            {
                if (current.Items.ContainsKey(UseBackupKey))
                {
                    m_backupCallContext.EndCallContext(threadId, nodeId);
                    return;
                }

                if (current.Items.ContainsKey(DictionaryKey))
                {
                    current.Items.Remove(DictionaryKey);

                    if (current.Items.ContainsKey(ContextStack))
                    {
                        if (current.Items[ContextStack] is Stack <Dictionary <string, object> > dataStack && dataStack.Count > 0)
                        {
                            current.Items[DictionaryKey] = dataStack.Pop();
                        }
                    }
                }
#if DEBUG
                else
                {
                    throw new InvalidOperationException("Attempting to end a HttpCallContext that has not been started.");
                }
#endif
            }
            else
            {
                m_backupCallContext.EndCallContext(threadId, nodeId);
            }
        }