/// <summary> /// Matches an event context property to a property /// </summary> /// <param name="context"> /// The event context containing the property to compare /// </param> /// <param name="prop"> /// The property to match /// </param> /// <returns> /// True if the event context matches the property /// False otherwise /// </returns> private Boolean Match(EventContext context, Property prop) { Object eValue = context.GetProperty(prop.Name); Object pValue = prop.Value; if (eValue == null && pValue == null) return true; if (eValue == null || pValue == null) return false; try { return (prop.Except != prop.Comparer.Equals(eValue, pValue)); } catch { return false; } }
/// <summary> /// Initializes a new event instance /// </summary> /// <param name="context"> /// The current event context /// </param> /// <param name="propNames"> /// The list of properties to sample /// from the event context /// </param> internal Event(EventContext context, IEnumerable<String> propNames) { this.props = propNames .Select(p => new KeyValuePair<String, Object>(p, context.GetProperty(p))) .ToList() .AsReadOnly(); this.map = new Hashtable( this.props.ToDictionary(p => p.Key, p => p.Value), StringComparer.OrdinalIgnoreCase ); }