本文整理汇总了C#中System.__DTString.MatchWords方法的典型用法代码示例。如果您正苦于以下问题:C# __DTString.MatchWords方法的具体用法?C# __DTString.MatchWords怎么用?C# __DTString.MatchWords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.__DTString
的用法示例。
在下文中一共展示了__DTString.MatchWords方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Lex
//
// This is the lexer. Check the character at the current index, and put the found token in dtok and
// some raw date/time information in raw.
//
private static void Lex(
int dps, __DTString str, DateTimeToken dtok, DateTimeRawInfo raw, DateTimeResult result, ref DateTimeFormatInfo dtfi) {
int sep;
dtok.dtt = DTT_Unk; // Assume the token is unkown.
//
// Skip any white spaces.
//
if (!str.SkipWhiteSpaceComma()) {
//
// SkipWhiteSpaceComma() will return true when end of string is reached.
//
dtok.dtt = DTT_End;
return;
}
char ch = str.GetChar();
if (Char.IsLetter(ch))
{
//
// This is a letter.
//
int month, dayOfWeek, era, timeMark;
//
// Check if this is a beginning of a month name.
// And check if this is a day of week name.
//
if (raw.month == -1 && (month = GetMonthNumber(str, dtfi)) >= 1)
{
//
// This is a month name
//
switch(sep=GetSeparator(str, raw, dtfi))
{
case SEP_End:
dtok.dtt = DTT_MonthEnd;
break;
case SEP_Space:
dtok.dtt = DTT_MonthSpace;
break;
case SEP_Date:
dtok.dtt = DTT_MonthDatesep;
break;
default:
//Invalid separator after month name
throw new FormatException(Environment.GetResourceString("Format_BadDateTime"));
}
raw.month = month;
}
else if (raw.dayOfWeek == -1 && (dayOfWeek = GetDayOfWeekNumber(str, dtfi)) >= 0)
{
//
// This is a day of week name.
//
raw.dayOfWeek = dayOfWeek;
dtok.dtt = DTT_DayOfWeek;
//
// Discard the separator.
//
GetSeparator(str, raw, dtfi);
}
else if (GetTimeZoneName(str))
{
//
// This is a timezone designator
//
// NOTENOTE : for now, we only support "GMT" and "Z" (for Zulu time).
//
dtok.dtt = DTT_TimeZone;
result.timeZoneUsed = true;
result.timeZoneOffset = new TimeSpan(0);
} else if ((raw.era == -1) && ((era = GetEra(str, result, ref dtfi)) != -1)) {
raw.era = era;
dtok.dtt = DTT_Era;
} else if (raw.timeMark == -1 && (timeMark = GetTimeMark(str, dtfi)) != -1) {
raw.timeMark = timeMark;
GetSeparator(str, raw, dtfi);
} else {
//
// Not a month name, not a day of week name. Check if this is one of the
// known date words. This is used to deal case like Spanish cultures, which
// uses 'de' in their Date string.
//
//
if (!str.MatchWords(dtfi.DateWords)) {
throw new FormatException(
String.Format(Environment.GetResourceString("Format_UnknowDateTimeWord"), str.Index));
}
GetSeparator(str, raw, dtfi);
}
} else if (Char.IsDigit(ch)) {
if (raw.numCount == 3) {
throw new FormatException(Environment.GetResourceString("Format_BadDateTime"));
//.........这里部分代码省略.........