internal string ToString(PatternSettings settings, RegexOptions options) { var builder = new PatternBuilder(settings, options); builder.Append(this); return(builder.ToString()); }
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(); }
public string AddComments(string pattern, PatternSettings settings) { _index = 0; _sb = new StringBuilder(); _spaces = CreateSpaces(_maxOptions); string[] splits = _newLineRegex.Split(pattern); int maxLength = splits.Max(f => f.Length); var isFirst = true; foreach (string split in splits) { if (isFirst) { isFirst = false; } else { _sb.Append(settings.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(); } }
internal PatternBuilder(PatternSettings settings, RegexOptions options) { if (settings == null) throw new ArgumentNullException(nameof(settings)); _sb = new StringBuilder(); _fFormat = settings.HasOptions(PatternOptions.Format); _fComment = _fFormat && settings.HasOptions(PatternOptions.Comment); _fInlineOptions = _fFormat && settings.HasOptions(PatternOptions.InlineOptions); _fBuilder = _fComment || _fInlineOptions; _fLiteral = settings.HasOptions(PatternOptions.CSharpLiteral) || settings.HasOptions(PatternOptions.VisualBasicLiteral); Settings = settings; if (_fBuilder) _builder = new LineInfoBuilder(); CurrentOptions = RegexOptionsHelper.GetInlineOptions(options); }
public string AddComments(string pattern, PatternSettings settings) { _index = 0; _sb = new StringBuilder(); _spaces = CreateSpaces(_maxOptions); 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(settings.NewLine); _sb.Append(split); AppendComment(maxLength - split.Length + 1); _index++; } return _sb.ToString(); }
/// <summary> /// Constructs a pattern text that represents the current instance with settings that modify the pattern. /// </summary> /// <param name="settings">A settings that modify the pattern.</param> /// <returns></returns> public string ToString(PatternSettings settings) { return(ToString(settings, RegexOptions.None)); }
internal PatternBuilder(PatternSettings settings) : this(settings, RegexOptions.None) { }