public override bool Evaluate(DiagnosticEvent diagnosticEvent, ILoggerName loggerName) { bool meetsCriteria = false; DiagnosticEventProperty property = new DiagnosticEventProperty(); if (!diagnosticEvent.Properties.TryGetProperty(Property, out property)) { Diag.Log.Warning(() => "Diagnostic Property '{0}' not found on Diagnostic Event." .FormatWith(Property)); meetsCriteria = false; } else { meetsCriteria = Evaluator.Value.MatchesPattern(property.Value.ToString()); } if (Mode == FilterMode.Include) return meetsCriteria; else return !meetsCriteria; }
CollectData(IList<DataRequest> requestedContextData) { var result = new List<DiagnosticEventProperty>(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]; DiagnosticEventProperty property = null; //# try to get from cache first if (DataRequestCache.TryGetValue(item, out property)) { result.Add(property); continue; } //# get the data var dataValue = (object)null; if (TryGetData(item, cx, out dataValue)) { property = new DiagnosticEventProperty(); property.UniqueName = item.Data; property.Value = dataValue; } result.AddIfNotNull(property); // add to cache if needed if (item.IsCached && !DataRequestCache.ContainsKey(item)) DataRequestCache.Add(item, property); } return result; }