Example #1
0
 /**
  * Add a training handler which is notified when "id" is detected
  * Important: does not check if "id" has actually been trained upon
  * @throws ArgumentException when id less than or equal to zero
  */
 public void AddTrainedHandler(int id, SharpBCITrainedHandler handler)
 {
     if (id <= 0)
     {
         throw new ArgumentException("Training id invalid");
     }
     lock (trainedHandlers)
     {
         if (!trainedHandlers.ContainsKey(id))
         {
             trainedHandlers.Add(id, new List <SharpBCITrainedHandler>());
         }
         trainedHandlers[id].Add(handler);
     }
 }
Example #2
0
 /**
  * Remove a previously added training handler
  * Important: does not check if "id" has actually been trained upon
  * @throws ArgumentException when id less than or equal to zero or if training handler was not previously added
  */
 public void RemoveTrainedHandler(int id, SharpBCITrainedHandler handler)
 {
     if (id <= 0)
     {
         throw new ArgumentException("Training id invalid");
     }
     lock (trainedHandlers)
     {
         if (!trainedHandlers.ContainsKey(id))
         {
             throw new ArgumentException("No handlers registered for id: " + id);
         }
         if (!trainedHandlers[id].Remove(handler))
         {
             throw new ArgumentException("Handler '" + handler + "' not registered for id: " + id);
         }
     }
 }