示例#1
0
 /// <summary>
 /// Get the total count of the given event.
 /// </summary>
 /// <param name="fr">The event (level2 is optional)</param>
 public int this[DataflowEvent fr]
 {
     get
     {
         IntHolder counter;
         if (this.m_eventCounter.TryGetValue(fr, out counter))
         {
             return(counter.Count);
         }
         else
         {
             if (fr.Level2 == null)
             {
                 //sum up all counters with same level1 if the query only has level1
                 return(this.m_eventCounter.
                        Where(kvPair => kvPair.Key.Level1 == fr.Level1).
                        Sum(kvPair => kvPair.Value.Count));
             }
             else
             {
                 return(0);
             }
         }
     }
 }
示例#2
0
        /// <summary>
        /// Record once for a certain dataflow event
        /// </summary>
        /// <param name="eventToAggregate">The event to record</param>
        public void RecordEvent(DataflowEvent eventToAggregate)
        {
            if (DataflowEvent.IsEmpty(eventToAggregate))
            {
                return;                                          //ignore empty event
            }
            IntHolder intHolder;

            if (!m_eventCounter.TryGetValue(eventToAggregate, out intHolder))
            {
                intHolder = this.m_eventCounter.GetOrAdd(eventToAggregate, new IntHolder());
            }
            intHolder.Increment();
        }
示例#3
0
 /// <summary>
 /// Checks if the given dataflow event is an empty event
 /// </summary>
 /// <param name="flowEvent">The dataflow event to check</param>
 public static bool IsEmpty(DataflowEvent flowEvent)
 {
     return(flowEvent.Level1 == null && flowEvent.Level2 == null);
 }