public void Operate() { if (PreCondition.Check()) { OperateInner(); } //Con.WriteLine("BaseOperate"); }
public IEnumerable <ConditionElementResult> Check(IEnumerable <T> objects, Architecture architecture) { if (_condition == null) { throw new InvalidOperationException( "Can't check a ConditionElement before the condition is set."); } return(_condition.Check(objects, architecture) .Select(result => new ConditionElementResult(result, _logicalConjunction))); }
private static List <T> Filter <T>(IEnumerable <T> array, ICondition <T> cond) { var result = new List <T>(); foreach (var item in array) { if (cond.Check(item)) { result.Add(item); } } return(result); }
private bool Accessible(World world, State startState) { var states = new List <State>() { startState }; foreach (var step in scenario) { states = states.SelectMany(s => world.GetEdges(s) .Where(e => e.Action.Equals(step.Action) && e.Actor.Equals(step.Actor)).Select(e => e.To)).ToList(); } //if (states.Count == 0) return false; return(states.All(s => gamma.Check(s))); }
private bool DFSearch(World world, HashSet <State> close, State state) { bool hasGammaBeenAchieved = gamma.Check(state); close.Add(state); // If there are some unvisited states and we haven't already found desired state if (!hasGammaBeenAchieved) { // Remove abnormal edges var edges = world.GetEdges(state).Where(edge => !edge.Abnormal); var actionGroups = edges.GroupBy(edge => new { edge.Action, edge.Actor }); // Check states grouped by their actions foreach (var group in actionGroups) { bool isAtLeastOneUnSuccessful = false; foreach (Edge e in group) { // Check if state can be visited State s = e.To; // If there's action that leads to already visited state we have a cycle - may cause always query to fail! if (close.Contains(s)) { isAtLeastOneUnSuccessful = true; continue; } // Recursively check if it leads to gamma-satisfying state if (!DFSearch(world, close, s)) { isAtLeastOneUnSuccessful = true; } } // If all paths are leading to satisfying state we're good to go if (!isAtLeastOneUnSuccessful) { hasGammaBeenAchieved = true; } } } close.Remove(state); return(hasGammaBeenAchieved); }
private bool Accessible(World world, State state) { var open = new HashSet <State>(world.GetEdges(state).Select(edge => edge.To)); var close = new HashSet <State>(); while (open.Count > 0) { var state2 = open.First(); if (gamma.Check(state2)) { return(true); } open.Remove(state2); close.Add(state2); foreach (var state3 in world.GetEdges(state2).Select(edge => edge.To).Distinct()) { if (!close.Contains(state3)) { open.Add(state3); } } } return(false); }
public bool IsTriggered(IEvent firedEvent) { return(EventSocket.Accepts(firedEvent) && _condition.Check()); }
public bool Check() { return(!condition.Check()); }
public Boolean Check() { return(_content.Check()); }
public bool Check(State state) { return(!from.Check(state) || to.Check(state)); }
public bool Check(State state) { return(!(right.Check(state) ^ left.Check(state))); }
/// <summary> /// Returns inverted result of testing the underlying condition. /// </summary> /// <param name="subject">Subject to test condition for.</param> /// <returns>False if <paramref name="subject"/> meets underlying condition and true otherwise.</returns> public bool Check(T subject) { return(!_condition.Check(subject)); }
public bool Check(State state) { return(!condition.Check(state)); }
/// <summary> /// <see cref="IElement.Check" /> /// </summary> public override bool Check(bool deep) { return(_ifCondition != null && (!deep || (_ifCondition.Check(true) && (_ifInstruction == null || _ifInstruction.Check(true)) && (_elseInstruction == null || _elseInstruction.Check(true))))); }
/// <summary> /// <see cref="IElement.Check" /> /// </summary> public override bool Check(bool blnDeep) { return(_condition != null && (!blnDeep || _condition.Check(true))); }