public void OnNewAlert(object sender, NewAlertEventArgs e) { var chosenBehavior = AlertBehaviors.FirstOrDefault(behavior => behavior.IsMatching(e.Alert)); if (chosenBehavior != null) { chosenBehavior.HandleAlert(e.Alert); return; } NoMatchingBehaviorBehavior.HandleAlert(e.Alert); }
public MonitoringUnitController( IEnumerable <ISubsystemMonitoringUnit> units, IEnumerable <IAlertBehavior> behaviors, NoMatchingBehaviorBehavior noMatchingBehavior) { SetUpLists(); Units.AddRange(units); AlertBehaviors.AddRange(behaviors); NoMatchingBehaviorBehavior = noMatchingBehavior; HookMonitoringUnitEvents(); }