private ExplorerContext( SubString text, IRule?interleaveRule, bool isInterleaveMatched, int depth, IImmutableSet <IRule> ruleNameExcepts, AmbiantRuleProperties ambiantRuleProperties) { if (depth <= 0) { throw new ArgumentOutOfRangeException(nameof(depth)); } _interleaveRule = interleaveRule; _isInterleaveMatched = isInterleaveMatched; _ruleExcepts = ruleNameExcepts; _ambiantRuleProperties = ambiantRuleProperties; Text = text; Depth = depth; ContextID = Guid.NewGuid().GetHashCode(); }
private IImmutableSet <IRule>?GetNewRuleExceptions( AmbiantRuleProperties newAmbiantRuleProperties, IRule rule) { if (!string.IsNullOrWhiteSpace(rule.RuleName) && !newAmbiantRuleProperties.IsRecursive && !newAmbiantRuleProperties.IsTerminalRule) { if (_ruleExcepts.Contains(rule)) { // Recursion into the same rule has been exhausted return(null); } else { return(_ruleExcepts.Add(rule)); } } else { return(_ruleExcepts); } }