コード例 #1
0
        public IDiagnosticEventPropertyCollection CollectData(IReadOnlyList<IDataRequest> requestedContextData)
        {
            var result = new DiagnosticEventPropertyCollection(capacity: requestedContextData.Count);

            if (requestedContextData.Count == 0)
                return result;

            var cx = new DataCollectionContext();

            for (int i = 0; i < requestedContextData.Count; i++)
            {
                var item = requestedContextData[i];

                IDiagnosticEventProperty property = null;

                //# try to get from cache first
                if (DataRequestCache.TryGetValue(item, out property))
                {
                    result.AddOrUpdate(property);
                    continue;
                }

                //# get the data
                var dataValue = (object)null;

                if (TryGetData(item, cx, out dataValue))
                {
                    var newProperty = new DiagnosticEventProperty();
                    newProperty.UniqueName = item.Data;
                    newProperty.Value = dataValue;

                    property = newProperty;

                    result.AddOrUpdate(property);

                    // add to cache if needed
                    if (item.IsCached && !DataRequestCache.ContainsKey(item))
                        DataRequestCache.AddOrUpdate(item, property);
                }
            }

            return result;
        }
コード例 #2
0
        public DiagnosticEvent()
        {
            Properties = new DiagnosticEventPropertyCollection(capacity: 27);

            Properties.AddOrUpdate("Event.HasCallerInfo", false);

            LoggerName = "";

            AttachedObjects = new AttachedObjectCollection();
        }