Exemple #1
0
        /// <summary>
        /// Start the call context
        /// </summary>
        /// <returns>id of the context node</returns>
        public Guid?StartCallContext()
        {
            HttpContext current = HttpContextWrapper.Current;

            if (current != null)
            {
                if (current.Items.ContainsKey(UseBackupKey))
                {
                    return(m_backupCallContext.StartCallContext());
                }

                if (!current.Items.ContainsKey(DataKey))
                {
                    current.Items[DataKey] = new ConcurrentDictionary <string, object>(StringComparer.Ordinal);
                }

                if (current.Items.ContainsKey(DictionaryKey))
                {
                    Stack <Dictionary <string, object> > dataStack = null;
                    if (current.Items.ContainsKey(ContextStack))
                    {
                        dataStack = current.Items[ContextStack] as Stack <Dictionary <string, object> >;
                    }
                    else
                    {
                        dataStack = new Stack <Dictionary <string, object> >();
                        current.Items[ContextStack] = dataStack;
                    }

                    dataStack.Push(current.Items[DictionaryKey] as Dictionary <string, object>);
                }

                current.Items[DictionaryKey] = null;
            }
            else
            {
                return(m_backupCallContext.StartCallContext());
            }

            return(null);
        }
        /// <summary>
        /// Start the call context
        /// </summary>
        /// <returns>id of the context node</returns>
        public Guid? StartCallContext()
        {
            OperationContext context = OperationContext.Current;
            if (context != null)
            {
                Stack<Dictionary<string, object>> dataStack = s_contextData.GetOrAdd(context, (operationContext) => new Stack<Dictionary<string, object>>());
                dataStack.Push(null);
            }
            else
            {
                return m_backupCallContext.StartCallContext();
            }

            return null;
        }