Esempio n. 1
0
        private static Dictionary <string, object> TranslateHeaders(object headers)
        {
            Dictionary <string, object> _headers = null;

            if (headers != null)
            {
                if (headers is IDictionary <string, string> d1)
                {
                    _headers = new Dictionary <string, object>(d1.Count);
                    foreach (var pair in d1)
                    {
                        _headers[pair.Key] = pair.Value;
                    }
                }
                else if (headers is IDictionary <string, object> d2)
                {
                    _headers = new Dictionary <string, object>(d2.Count);
                    foreach (var pair in d2)
                    {
                        _headers[pair.Key] = pair.Value;
                    }
                }
                else
                {
                    _headers = TranslateObjectToDictionnarySerializerExtension.GetDictionnaryProperties(headers);
                }
            }

            return(_headers);
        }
Esempio n. 2
0
        private Dictionary <string, object> DataCollect(object message, string category)
        {
            Dictionary <string, object> properties;

            if (message is string)
            {
                properties = new Dictionary <string, object>();
                properties.Add("Message", message);
            }
            else
            {
                properties = TranslateObjectToDictionnarySerializerExtension.GetDictionnaryProperties(message, true);
            }

            if ((TraceOutputOptions & TraceOptions.ProcessId) == TraceOptions.ProcessId)
            {
                properties.Add("ProcessId", Process.GetCurrentProcess().Id);
            }

            if ((TraceOutputOptions & TraceOptions.ThreadId) == TraceOptions.ThreadId)
            {
                properties.Add("ManagedThreadId", Thread.CurrentThread.ManagedThreadId);
            }

            if ((TraceOutputOptions & TraceOptions.DateTime) == TraceOptions.DateTime)
            {
                properties.Add("DateTime", RabbitClock.GetNow().ToString("u", Thread.CurrentThread.CurrentCulture));
            }

            else if ((TraceOutputOptions & TraceOptions.Timestamp) == TraceOptions.Timestamp)
            {
                properties.Add("Timestamp", RabbitClock.GetNow().ToString("u", Thread.CurrentThread.CurrentCulture));
            }

            if ((TraceOutputOptions & TraceOptions.LogicalOperationStack) == TraceOptions.LogicalOperationStack ||
                (TraceOutputOptions & TraceOptions.Callstack) == TraceOptions.Callstack)
            {
                var stack = GetStack();
            }

            properties.Add("TraceLevel", category);
            return(properties);
        }