Specifies a set of features to support on the PatternBuilder object. This class cannot be inherited.
Ejemplo n.º 1
0
        internal string ToString(PatternSettings settings, RegexOptions options)
        {
            var builder = new PatternBuilder(settings, options);

            builder.Append(this);
            return(builder.ToString());
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
 /// <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));
 }
Ejemplo n.º 8
0
 internal PatternBuilder(PatternSettings settings)
     : this(settings, RegexOptions.None)
 {
 }