Specifies a set of features to support on the PatternBuilder object. This class cannot be inherited.
コード例 #1
0
ファイル: Pattern.cs プロジェクト: tralivali1234/LinqToRegex
        internal string ToString(PatternSettings settings, RegexOptions options)
        {
            var builder = new PatternBuilder(settings, options);

            builder.Append(this);
            return(builder.ToString());
        }
コード例 #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();
        }
コード例 #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());
        }
コード例 #4
0
ファイル: PatternBuilder.cs プロジェクト: arsalan/LinqToRegex
        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();
            }
        }
コード例 #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);
        }
コード例 #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();
        }
コード例 #7
0
ファイル: Pattern.cs プロジェクト: tralivali1234/LinqToRegex
 /// <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));
 }
コード例 #8
0
 internal PatternBuilder(PatternSettings settings)
     : this(settings, RegexOptions.None)
 {
 }