Esempio n. 1
0
        public static void Pop(ILoggingContext context)
        {
            var frameID = GetFrameID(context);

            var frame = new LoggingCallContextStackFrame(frameID);

            if (!frame.Deactivate())
            {
                return;
            }

            using (var keySet = Keys().GetEditor())
            {
                foreach (var key in frame.Keys)
                {
                    var activeFrameData = new LoggingCallContextActiveFrameData(key);

                    LoggingCallContextStackFrame currentFrame;
                    while (activeFrameData.TryGetFrame(out currentFrame) &&
                           !currentFrame.IsActive())
                    {
                        currentFrame.FreeKey(key);

                        if (!activeFrameData.Pop())
                        {
                            keySet.Remove(key);
                            break;
                        }
                    }
                }

                CallContext.LogicalSetData(SERIALIZATION_KEY, SerializeToXML(keySet.DataStore()));
            }
        }
Esempio n. 2
0
        public static bool TryGetContextData(ILoggingContext ctx, string key, out object result)
        {
            var frame = new LoggingCallContextStackFrame(GetFrameID(ctx));

            if (!frame.IsActive())
            {
                result = null;
                return(false);
            }

            return(frame.GetValue(key, out result));
        }
Esempio n. 3
0
        public bool TryGetFrame(out LoggingCallContextStackFrame result)
        {
            string frameID;

            if (!FrameStack(_key).TryPeek(out frameID))
            {
                result = null;
                return(false);
            }

            result = new LoggingCallContextStackFrame(frameID);
            return(true);
        }
Esempio n. 4
0
        public static ILoggingContext Push(IEnumerable <KeyValuePair <string, object> > data)
        {
            var context = new LoggingContext();
            var frame   = LoggingCallContextStackFrame.Initialize(context, data);

            using (var keySet = Keys().GetEditor())
            {
                foreach (var key in frame.Keys)
                {
                    LoggingCallContextActiveFrameData.Initialize(frame, key);
                    keySet.Add(key);
                }

                CallContext.LogicalSetData(SERIALIZATION_KEY, SerializeToXML(keySet.DataStore()));
            }

            return(context);
        }
Esempio n. 5
0
        public static LoggingCallContextActiveFrameData Initialize(LoggingCallContextStackFrame frame, string key)
        {
            FrameStack(key).Push(frame.FrameID);

            return(new LoggingCallContextActiveFrameData(key));
        }