Pihrtsoft.Text.RegularExpressions.Linq.PatternBuilder.AppendIfAssert C# (CSharp) Method

AppendIfAssert() public method

Appends an if construct.
public AppendIfAssert ( object testContent, object trueContent, object falseContent ) : void
testContent object The pattern to assert.
trueContent object The pattern to match if the assertion succeeds.
falseContent object The pattern to match if the assertion fails.
return void
        public void AppendIfAssert(object testContent, object trueContent, object falseContent)
        {
            if (testContent == null)
                throw new ArgumentNullException(nameof(testContent));

            if (trueContent == null)
                throw new ArgumentNullException(nameof(trueContent));

            AppendGroupStart();
            AppendDirect('(');

            if (_fBuilder)
                _builder.AddInfo(SyntaxKind.IfAssert);

            if (!Settings.HasOptions(PatternOptions.IfConditionWithoutAssertion))
                AppendDirect("?=");

            AppendGroupContent(testContent);
            AppendGroupEnd();

            RegexOptions currentOptions = CurrentOptions;

            _indentLevel++;

            if (falseContent == null)
            {
                Append(trueContent, GroupMode.None);
            }
            else
            {
                Append(trueContent);
                AppendOr(falseContent);
            }

            AppendGroupEnd();

            CurrentOptions = currentOptions;
        }

Usage Example

Example #1
0
 internal override void AppendTo(PatternBuilder builder)
 {
     builder.AppendIfAssert(_testContent, _trueContent, _falseContent);
 }