Пример #1
0
        public void Append(string phrase, int minRepeat, int maxRepeat)
        {
            Helpers.ThrowIfEmptyOrNull(phrase, nameof(phrase));
            GrammarBuilder.ValidateRepeatArguments(minRepeat, maxRepeat, "minRepeat", "maxRepeat");

            // Wrap the phrase in an item if min and max repeat are set
            GrammarBuilderPhrase elementPhrase = new(phrase);

            if (minRepeat != 1 || maxRepeat != 1)
            {
                AddItem(new ItemElement(elementPhrase, minRepeat, maxRepeat));
            }
            else
            {
                AddItem(elementPhrase);
            }
        }
Пример #2
0
        public void Append(GrammarBuilder builder, int minRepeat, int maxRepeat)
        {
            Helpers.ThrowIfNull(builder, nameof(builder));
            GrammarBuilder.ValidateRepeatArguments(minRepeat, maxRepeat, "minRepeat", "maxRepeat");

            // Should never happens has it is a RO value
            Helpers.ThrowIfNull(builder.InternalBuilder, "builder.InternalBuilder");

            // Wrap the phrase in an item if min and max repeat are set
            if (minRepeat != 1 || maxRepeat != 1)
            {
                AddItem(new ItemElement(builder.InternalBuilder.Items, minRepeat, maxRepeat));
            }
            else
            {
                Append(builder);
            }
        }