Example #1
0
        public static void SetContextItem(object key, object value)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            ContextItems.SetContextItem(key, value);
        }
Example #2
0
        public static void SetContextItem(object key, object value)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            if (value is string && !string.IsNullOrEmpty(value as string))
            {
                // remove any curly braces as they cause FormatException in WriteEvent method when args is passed to it.
                var stringValue = ((string)value).Replace("{", string.Empty).Replace("}", string.Empty);
                ContextItems.SetContextItem(key, stringValue);
            }
            else
            {
                ContextItems.SetContextItem(key, value);
            }
        }