TryMatchText() public method

Matches a string without setting an error if match fails.
public TryMatchText ( string s, System.StringComparison comparisonType = StringComparison.OrdinalIgnoreCase ) : bool
s string The string that must match. Can not be null nor empty.
comparisonType System.StringComparison Specifies the culture, case, and sort rules.
return bool
コード例 #1
0
 static bool MatchOriginatorAndTime(StringMatcher m, out Guid id, out DateTimeStamp time)
 {
     time = DateTimeStamp.MinValue;
     if (!m.TryMatchGuid(out id))
     {
         return(false);
     }
     if (!m.TryMatchText(" at "))
     {
         return(false);
     }
     return(m.MatchDateTimeStamp(out time));
 }
コード例 #2
0
            /// <summary>
            /// Tries to parse a <see cref="DependentToken.ToString()"/> string.
            /// </summary>
            /// <param name="s">The string to parse.</param>
            /// <param name="t">The resulting dependent token.</param>
            /// <returns>True on success, false otherwise.</returns>
            static public bool TryParse(string s, out DependentToken t)
            {
                t = null;
                StringMatcher m = new StringMatcher(s);
                Guid          id;
                DateTimeStamp time;

                if (MatchOriginatorAndTime(m, out id, out time) && m.TryMatchText(" with"))
                {
                    string topic;
                    if (ExtractTopic(s, m.StartIndex, out topic))
                    {
                        t = new DependentToken(id, time, topic);
                        return(true);
                    }
                }
                return(false);
            }
コード例 #3
0
 public void string_matcher_TryMatchJSONQuotedString( string s, string parsed, string textAfter )
 {
     var m = new StringMatcher( s );
     string result;
     Assert.That( m.TryMatchJSONQuotedString( out result, true ) );
     Assert.That( result, Is.EqualTo( parsed ) );
     Assert.That( m.TryMatchText( textAfter ), "Should be followed by: " + textAfter );
     
     m = new StringMatcher( s );
     Assert.That( m.TryMatchJSONQuotedString( true ) );
     Assert.That( m.TryMatchText( textAfter ), "Should be followed by: " + textAfter );
 }