static public bool Evaluate(this CompareOperator inComparison, string inCheck, string inValue) { inCheck = inCheck ?? string.Empty; inValue = inValue ?? string.Empty; switch (inComparison) { case CompareOperator.EqualTo: return(inCheck == inValue); case CompareOperator.NotEqualTo: return(inCheck != inValue); case CompareOperator.True: return(!string.IsNullOrEmpty(inCheck)); case CompareOperator.False: return(string.IsNullOrEmpty(inCheck)); case CompareOperator.Contains: return(inCheck.Contains(inValue)); case CompareOperator.StartsWith: return(inCheck.StartsWith(inValue)); case CompareOperator.EndsWith: return(inCheck.EndsWith(inValue)); case CompareOperator.DoesNotContain: return(!inCheck.Contains(inValue)); case CompareOperator.DoesNotStartWith: return(!inCheck.StartsWith(inValue)); case CompareOperator.DoesNotEndWith: return(!inCheck.EndsWith(inValue)); case CompareOperator.IsEmpty: return(string.IsNullOrEmpty(inValue)); case CompareOperator.IsNotEmpty: return(!string.IsNullOrEmpty(inValue)); case CompareOperator.Matches: return(ScriptUtils.StringMatch(inCheck, inValue)); case CompareOperator.DoesNotMatch: return(!ScriptUtils.StringMatch(inCheck, inValue)); default: throw InvalidComparisonException(inComparison); } }
public IEnumerable <T> EntitiesWithName(string inName) { foreach (var kv in m_NameMap) { if (ScriptUtils.StringMatch(kv.Key, inName)) { foreach (var entity in kv.Value) { yield return(entity); } } } }
public T EntityWithName(string inName) { foreach (var kv in m_NameMap) { if (ScriptUtils.StringMatch(kv.Key, inName)) { var enumerator = kv.Value.GetEnumerator(); if (enumerator.MoveNext()) { return(enumerator.Current); } } } return(null); }
/// <summary> /// Enables all rules with the given name. /// </summary> public void EnableRule(string inRuleName) { RSRuleData[] rules = m_Table?.Rules; if (rules == null || rules.Length <= 0) { return; } for (int i = 0; i < rules.Length; ++i) { RSRuleData rule = rules[i]; if (ScriptUtils.StringMatch(rule.Name, inRuleName)) { m_States[i] &= ~RuleState.Disabled; } } }
/// <summary> /// Stops execution of all rules with the given group. /// </summary> public void StopRuleGroup(string inGroupName) { RSRuleData[] rules = m_Table?.Rules; if (rules == null || rules.Length <= 0) { return; } for (int i = 0; i < rules.Length; ++i) { RSRuleData rule = rules[i]; if (ScriptUtils.StringMatch(rule.RoutineGroup, inGroupName)) { m_Routines[i].Stop(); } } }