TryMatchChar() public méthode

Attempts to match an exact single character.
public TryMatchChar ( char c ) : bool
c char The character that must match.
Résultat bool
Exemple #1
0
        public virtual bool VisitObjectContent()
        {
            int propertyIndex = 0;

            while (!_m.IsEnd)
            {
                _m.MatchWhiteSpaces(0);
                if (_m.TryMatchChar('}'))
                {
                    return(true);
                }
                int    startPropertyIndex = _m.StartIndex;
                string propName;
                if (!_m.TryMatchJSONQuotedString(out propName))
                {
                    return(false);
                }
                _m.MatchWhiteSpaces(0);
                if (!_m.MatchChar(':') || !VisitObjectProperty(startPropertyIndex, propName, propertyIndex))
                {
                    return(false);
                }
                _m.MatchWhiteSpaces(0);
                _m.TryMatchChar(',');
                ++propertyIndex;
            }
            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Matches a <see cref="DateTimeStamp"/>.
        /// </summary>
        /// <param name="this">This <see cref="StringMatcher"/>.</param>
        /// <param name="time">Resulting time stamp on successful match; <see cref="DateTimeStamp.Unknown"/> otherwise.</param>
        /// <returns>True if the time stamp has been matched.</returns>
        static public bool MatchDateTimeStamp(this StringMatcher @this, out DateTimeStamp time)
        {
            time = DateTimeStamp.Unknown;
            int      savedIndex = @this.StartIndex;
            DateTime t;

            if ([email protected](out t))
            {
                return(@this.SetError());
            }
            byte uniquifier = 0;

            if (@this.MatchChar('('))
            {
                int unique;
                if ([email protected](out unique, 0, 255) || [email protected](')'))
                {
                    return(@this.BackwardAddError(savedIndex));
                }
                uniquifier = (byte)unique;
            }
            time = new DateTimeStamp(t, uniquifier);
            return(@this.Forward(0));
        }