internal bool TryGetPatternRegex(out Regex regex, out string errorMessage)
        {
            bool result = RegexHelpers.TryGetPatternRegex(_pattern, ref _patternRegex, ref _patternError);

            regex        = _patternRegex;
            errorMessage = _patternError;

            return(result);
        }
        public void TryGetPatternRegex_ECMARegexPattern_Success()
        {
            string pattern = @"^-?(?:[1-9]\d{3}(-?)(?:(?:0[1-9]|1[0-2])\1(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])\1(?:29|30)|(?:0[13578]|1[02])(?:\1)31|00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[0-5]))|(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00)(?:(-?)02(?:\2)29|-?366))(?:Z|[+-][01]\d(?:\3[0-5]\d)?)$";

            Regex  regex1        = null;
            string errorMessage1 = null;
            bool   result1       = RegexHelpers.TryGetPatternRegex(pattern, null, ref regex1, ref errorMessage1);

            Assert.AreEqual(true, result1);
            Assert.AreEqual(RegexOptions.ECMAScript, regex1.Options);
        }
        public void TryGetPatternRegex_MatchTimeout_Null()
        {
            Regex  regex1        = null;
            string errorMessage1 = null;

            RegexHelpers.TryGetPatternRegex("[abc]", null, ref regex1, ref errorMessage1);

            Assert.IsNotNull(regex1);

            Regex  regex2        = regex1;
            string errorMessage2 = errorMessage1;

            RegexHelpers.TryGetPatternRegex("[abc]", null, ref regex2, ref errorMessage2);

            Assert.AreEqual(regex1, regex2);
        }
        public void TryGetPatternRegex_MatchTimeout_Defined()
        {
            TimeSpan matchTimeout = TimeSpan.FromSeconds(1);

            Regex  regex1        = null;
            string errorMessage1 = null;

            RegexHelpers.TryGetPatternRegex("[abc]", matchTimeout, ref regex1, ref errorMessage1);

            Assert.IsNotNull(regex1);

            Regex  regex2        = regex1;
            string errorMessage2 = errorMessage1;

            RegexHelpers.TryGetPatternRegex("[abc]", matchTimeout, ref regex2, ref errorMessage2);

            Assert.AreEqual(regex1, regex2);
        }
Пример #5
0
        internal bool TryGetPatternRegex(
#if !(NET35 || NET40)
            TimeSpan?matchTimeout,
#endif
            out Regex regex,
            out string errorMessage)
        {
            bool result = RegexHelpers.TryGetPatternRegex(
                _pattern,
#if !(NET35 || NET40)
                matchTimeout,
#endif
                ref _patternRegex,
                ref _patternError);

            regex        = _patternRegex;
            errorMessage = _patternError;

            return(result);
        }
Пример #6
0
        internal bool TryGetPatternRegex(
#if !(NET35 || NET40)
            TimeSpan?matchTimeout,
#endif
            [NotNullWhen(true)] out Regex?regex,
            [NotNullWhen(false)] out string?errorMessage)
        {
            bool result = RegexHelpers.TryGetPatternRegex(
                _pattern,
#if !(NET35 || NET40)
                matchTimeout,
#endif
                ref _patternRegex,
                ref _patternError);

            regex        = _patternRegex;
            errorMessage = _patternError;

            return(result);
        }