/// <summary> /// Raises an <see cref="Event"/> internally and returns from the execution context. /// </summary> /// <param name="e">Event</param> protected void Raise(Event e) { // If the event is null, then report an error and exit. this.Assert(e != null, $"Monitor '{this.GetType().Name}' is raising a null event."); EventInfo raisedEvent = new EventInfo(e, new EventOriginInfo( this.Id, this.GetType().Name, StateGroup.GetQualifiedStateName(this.CurrentState))); this.Runtime.NotifyRaisedEvent(this, raisedEvent); this.HandleEvent(e); }
/// <summary> /// Returns the set of all states in the monitor /// (for code coverage). /// </summary> /// <returns>Set of all states in the monitor</returns> internal HashSet <string> GetAllStates() { this.Assert(StateMap.ContainsKey(this.GetType()), $"Monitor '{this.Id}' hasn't populated its states yet."); var allStates = new HashSet <string>(); foreach (var state in StateMap[this.GetType()]) { allStates.Add(StateGroup.GetQualifiedStateName(state.GetType())); } return(allStates); }
/// <summary> /// Returns the set of all (states, registered event) pairs in the monitor /// (for code coverage). /// </summary> /// <returns>Set of all (states, registered event) pairs in the monitor</returns> internal HashSet <Tuple <string, string> > GetAllStateEventPairs() { this.Assert(StateMap.ContainsKey(this.GetType()), $"Monitor '{this.Id}' hasn't populated its states yet."); var pairs = new HashSet <Tuple <string, string> >(); foreach (var state in StateMap[this.GetType()]) { foreach (var binding in state.ActionBindings) { pairs.Add(Tuple.Create(StateGroup.GetQualifiedStateName(state.GetType()), binding.Key.Name)); } foreach (var transition in state.GotoTransitions) { pairs.Add(Tuple.Create(StateGroup.GetQualifiedStateName(state.GetType()), transition.Key.Name)); } } return(pairs); }