public string AddComments(string pattern, LineInfoCollection lines, PatternSettings settings) { _index = 0; _sb = new StringBuilder(); _lines = lines; string newLine = settings.NewLine; var splits = _newLineRegex.Split(pattern); int maxLength = splits.Max(f => f.Length); bool isFirst = true; foreach (var split in splits) { if (isFirst) { isFirst = false; } else { _sb.Append(newLine); } _sb.Append(split); AppendComment(maxLength - split.Length + 1); _index++; } return _sb.ToString(); }
internal PatternBuilder(PatternSettings settings, RegexOptions options) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } _settings = settings; _currentOptions = options; _format = settings.HasOptions(PatternOptions.Format); _comment = _format && settings.HasOptions(PatternOptions.Comment); _sb = new StringBuilder(); if (_comment) { _lines = new LineInfoCollection(); } }