SenseNet.Diagnostics.Utility.CollectAutoProperties C# (CSharp) Метод

CollectAutoProperties() публичный статический Метод

public static CollectAutoProperties ( object>.IDictionary properties ) : object>.IDictionary
properties object>.IDictionary
Результат object>.IDictionary
        public static IDictionary<string, object> CollectAutoProperties(IDictionary<string, object> properties)
        {
            var props = properties;
            if (props == null)
                props = new Dictionary<string, object>();
            if (props.IsReadOnly)
                props = new Dictionary<string, object>(props);

            CollectUserProperties(props);

            var nullNames = new List<string>();
            foreach (var key in props.Keys)
                if (props[key] == null)
                    nullNames.Add(key);
            foreach (var key in nullNames)
                props[key] = String.Empty;

            return props;
        }
        private static void CollectUserProperties(IDictionary<string, object> properties)

Usage Example

Пример #1
0
        public void Write(object message, ICollection <string> categories, int priority, int eventId, TraceEventType severity, string title, IDictionary <string, object> properties)
        {
            var props         = Utility.CollectAutoProperties(properties);
            var eventTypeName = severity.ToString().ToUpper();

            if (SnTrace.Event.Enabled)
            {
                if (severity <= TraceEventType.Information) // Critical = 1, Error = 2, Warning = 4, Information = 8
                {
                    var id = "#" + Guid.NewGuid().ToString();
                    props["SnTrace"] = id;
                    SnTrace.Event.Write("{0} {1}: {2}", eventTypeName, id, message);
                }
                else
                {
                    object id   = "-";
                    object path = "-";
                    if (properties != null)
                    {
                        properties.TryGetValue("Id", out id);
                        properties.TryGetValue("Path", out path);
                    }

                    if (categories.Count == 1 && categories.First() == "Audit")
                    {
                        eventTypeName = "Audit";
                    }
                    SnTrace.Event.Write("{0}: {1}, Id:{2}, Path:{3}", eventTypeName, message, id, path);
                }
            }

            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(
                message ?? String.Empty, categories ?? null,
                priority, eventId, severity, title ?? string.Empty, props);
        }
All Usage Examples Of SenseNet.Diagnostics.Utility::CollectAutoProperties