public static ICollection<EventBean> GetDistinctByProp( ArrayDeque<EventBean> events, EventPropertyValueGetter getter) { if (events == null || events.IsEmpty()) { return new EventBean[0]; } if (events.Count < 2) { return events; } var map = new LinkedHashMap<object, EventBean>(); if (events.First is NaturalEventBean) { foreach (var theEvent in events) { var inner = ((NaturalEventBean) theEvent).OptionalSynthetic; var key = getter.Get(inner); map[key] = inner; } } else { foreach (var theEvent in events) { var key = getter.Get(theEvent); map[key] = theEvent; } } return map.Values.ToArray(); }
/// <summary> /// Returns the distinct events by properties. /// </summary> /// <param name="events">to inspect</param> /// <param name="getter">for retrieving properties</param> /// <returns>distinct events</returns> public static EventBean[] GetDistinctByProp( EventBean[] events, EventPropertyValueGetter getter) { if (events == null || events.Length < 2 || getter == null) { return events; } var map = new Dictionary<object, EventBean>(); if (events[0] is NaturalEventBean) { foreach (var theEvent in events) { var inner = ((NaturalEventBean) theEvent).OptionalSynthetic; var key = getter.Get(inner); map[key] = theEvent; } } else { foreach (var theEvent in events) { var key = getter.Get(theEvent); map[key] = theEvent; } } return map.Values.ToArray(); }
public object Eval( EventBean @event, ExprEvaluatorContext ctx) { return(_getter.Get(@event)); }