private async void OnNewWorldStateObject(IWorldStateObject worldStateObject) { if (!Application.Settings.Alerts.Matches(worldStateObject)) { return; } Notify(await CreateControl(worldStateObject)); }
public bool Matches(IWorldStateObject worldStateObject) { return (Alerts .Where(alert => alert.Enabled && alert.MatchingRule == MatchingRule.Include) .Any(worldStateObject.Matches) && !Alerts .Where(alert => alert.Enabled && alert.MatchingRule == MatchingRule.Exclude) .Any(worldStateObject.Matches) ); }
private async Task <Control> CreateControl(IWorldStateObject worldStateObject) { switch (worldStateObject) { case Fissure fissure: var fissureControl = new FissureControl { ImageRepository = Application.ImageRepository, Active = true, }; fissureControl.Update(fissure, await Application.SolNodes); return(fissureControl); } throw new ApplicationException("Unrecognized world state object type."); }