private RuleTrimAttribute(string rule, int trimSymbolIndex, string trimSymbol, ArgumentExceptionDelegate notFoundException): base(rule) {
			if (trimSymbol == null) {
				throw new ArgumentNullException("trimSymbol");
			}
			int ruleHandleCount = 0;
			using (IEnumerator<string> ruleHandleEnumerator = RuleDeclarationParser.GetRuleHandleNames(ParsedRule).GetEnumerator()) {
				while (ruleHandleEnumerator.MoveNext()) {
					if (trimSymbol.Equals(ruleHandleEnumerator.Current)) {
						if (trimSymbolIndex >= 0) {
							throw new ArgumentException("The given symbol is ambigious in this rule", "trimSymbol");
						}
						trimSymbolIndex = ruleHandleCount;
					}
					ruleHandleCount++;
				}
			}
			if ((trimSymbolIndex < 0) || (trimSymbolIndex >= ruleHandleCount)) {
				throw notFoundException();
			}
			this.trimSymbolIndex = trimSymbolIndex;
		}
Esempio n. 2
0
        private RuleTrimAttribute(string rule, int trimSymbolIndex, string trimSymbol, ArgumentExceptionDelegate notFoundException) : base(rule)
        {
            if (trimSymbol == null)
            {
                throw new ArgumentNullException("trimSymbol");
            }
            int ruleHandleCount = 0;

            using (IEnumerator <string> ruleHandleEnumerator = RuleDeclarationParser.GetRuleHandleNames(ParsedRule).GetEnumerator()) {
                while (ruleHandleEnumerator.MoveNext())
                {
                    if (trimSymbol.Equals(ruleHandleEnumerator.Current))
                    {
                        if (trimSymbolIndex >= 0)
                        {
                            throw new ArgumentException("The given symbol is ambigious in this rule", "trimSymbol");
                        }
                        trimSymbolIndex = ruleHandleCount;
                    }
                    ruleHandleCount++;
                }
            }
            if ((trimSymbolIndex < 0) || (trimSymbolIndex >= ruleHandleCount))
            {
                throw notFoundException();
            }
            this.trimSymbolIndex = trimSymbolIndex;
        }