本文整理汇总了C#中System.DateTimeRawInfo.AddNumber方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeRawInfo.AddNumber方法的具体用法?C# DateTimeRawInfo.AddNumber怎么用?C# DateTimeRawInfo.AddNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTimeRawInfo
的用法示例。
在下文中一共展示了DateTimeRawInfo.AddNumber方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Lex
private static bool Lex(DateTimeParse.DS dps, ref __DTString str, ref DateTimeToken dtok, ref DateTimeRawInfo raw, ref DateTimeResult result, ref DateTimeFormatInfo dtfi)
{
dtok.dtt = DateTimeParse.DTT.Unk;
TokenType tokenType;
int num;
str.GetRegularToken(out tokenType, out num, dtfi);
switch (tokenType)
{
case TokenType.NumberToken:
case TokenType.YearNumberToken:
{
if (raw.numCount == 3 || num == -1)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
if (dps == DateTimeParse.DS.T_NNt && str.Index < str.len - 1)
{
char c = str.Value[str.Index];
if (c == '.')
{
DateTimeParse.ParseFraction(ref str, out raw.fraction);
}
}
if ((dps == DateTimeParse.DS.T_NNt || dps == DateTimeParse.DS.T_Nt) && str.Index < str.len - 1 && !DateTimeParse.HandleTimeZone(ref str, ref result))
{
return false;
}
dtok.num = num;
if (tokenType != TokenType.YearNumberToken)
{
int index;
char current;
TokenType separatorToken;
TokenType tokenType2 = separatorToken = str.GetSeparatorToken(dtfi, out index, out current);
if (separatorToken > TokenType.SEP_YearSuff)
{
if (separatorToken <= TokenType.SEP_HourSuff)
{
if (separatorToken == TokenType.SEP_MonthSuff || separatorToken == TokenType.SEP_DaySuff)
{
dtok.dtt = DateTimeParse.DTT.NumDatesuff;
dtok.suffix = tokenType2;
break;
}
if (separatorToken != TokenType.SEP_HourSuff)
{
goto IL_52A;
}
}
else
{
if (separatorToken <= TokenType.SEP_SecondSuff)
{
if (separatorToken != TokenType.SEP_MinuteSuff && separatorToken != TokenType.SEP_SecondSuff)
{
goto IL_52A;
}
}
else
{
if (separatorToken == TokenType.SEP_LocalTimeMark)
{
dtok.dtt = DateTimeParse.DTT.NumLocalTimeMark;
raw.AddNumber(dtok.num);
break;
}
if (separatorToken != TokenType.SEP_DateOrOffset)
{
goto IL_52A;
}
if (DateTimeParse.dateParsingStates[(int)dps][4] == DateTimeParse.DS.ERROR && DateTimeParse.dateParsingStates[(int)dps][3] > DateTimeParse.DS.ERROR)
{
str.Index = index;
str.m_current = current;
dtok.dtt = DateTimeParse.DTT.NumSpace;
}
else
{
dtok.dtt = DateTimeParse.DTT.NumDatesep;
}
raw.AddNumber(dtok.num);
break;
}
}
dtok.dtt = DateTimeParse.DTT.NumTimesuff;
dtok.suffix = tokenType2;
break;
}
if (separatorToken <= TokenType.SEP_Am)
{
if (separatorToken == TokenType.SEP_End)
{
dtok.dtt = DateTimeParse.DTT.NumEnd;
raw.AddNumber(dtok.num);
break;
}
if (separatorToken == TokenType.SEP_Space)
{
dtok.dtt = DateTimeParse.DTT.NumSpace;
//.........这里部分代码省略.........
示例2: Lex
//.........这里部分代码省略.........
dtok.dtt = DTT.NumDatesuff;
dtok.suffix = sep;
break;
case TokenType.SEP_HourSuff:
case TokenType.SEP_MinuteSuff:
case TokenType.SEP_SecondSuff:
dtok.dtt = DTT.NumTimesuff;
dtok.suffix = sep;
break;
default:
// Invalid separator after number number.
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
LexTraceExit("0040 (Invalid separator after number)", dps);
return false;
}
//
// Found the token already. Return now.
//
LexTraceExit("0050 (success)", dps);
return true;
}
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
LexTraceExit("0060", dps);
return false;
}
switch (sep = str.GetSeparatorToken(dtfi, out indexBeforeSeparator, out charBeforeSeparator))
{
//
// Note here we check if the numCount is less than three.
// When we have more than three numbers, it will be caught as error in the state machine.
//
case TokenType.SEP_End:
dtok.dtt = DTT.NumEnd;
raw.AddNumber(dtok.num);
break;
case TokenType.SEP_Am:
case TokenType.SEP_Pm:
if (raw.timeMark == TM.NotSet) {
raw.timeMark = (sep == TokenType.SEP_Am ? TM.AM : TM.PM);
dtok.dtt = DTT.NumAmpm;
// Fix AM/PM parsing case, e.g. "1/10 5 AM"
if (dps == DS.D_NN
#if !FEATURE_CORECLR
&& enableAmPmParseAdjustment
#endif
)
{
if (!ProcessTerminaltState(DS.DX_NN, ref result, ref styles, ref raw, dtfi))
{
return false;
}
}
raw.AddNumber(dtok.num);
} else {
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
break;
}
if (dps == DS.T_NNt || dps == DS.T_Nt) {
if (false == HandleTimeZone(ref str, ref result))
{
LexTraceExit("0070 (HandleTimeZone returned false)", dps);
return false;
}
}
break;
示例3: Lex
private static bool Lex(DS dps, ref __DTString str, ref DateTimeToken dtok, ref DateTimeRawInfo raw, ref DateTimeResult result, ref DateTimeFormatInfo dtfi)
{
TokenType type;
int num;
int num2;
char ch;
TokenType type2;
dtok.dtt = DTT.Unk;
str.GetRegularToken(out type, out num, dtfi);
switch (type)
{
case TokenType.NumberToken:
case TokenType.YearNumberToken:
if ((raw.numCount != 3) && (num != -1))
{
if ((dps == DS.T_NNt) && (str.Index < (str.len - 1)))
{
char ch2 = str.Value[str.Index];
if (ch2 == '.')
{
ParseFraction(ref str, out raw.fraction);
}
}
if (((dps == DS.T_NNt) || (dps == DS.T_Nt)) && (str.Index < (str.len - 1)))
{
char c = str.Value[str.Index];
int num3 = 0;
while (char.IsWhiteSpace(c) && ((str.Index + num3) < (str.len - 1)))
{
num3++;
c = str.Value[str.Index + num3];
}
switch (c)
{
case '+':
case '-':
str.Index += num3;
if ((result.flags & ParseFlags.TimeZoneUsed) != 0)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
result.flags |= ParseFlags.TimeZoneUsed;
if (!ParseTimeZone(ref str, ref result.timeZoneOffset))
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
break;
}
}
dtok.num = num;
if (type != TokenType.YearNumberToken)
{
switch ((type2 = str.GetSeparatorToken(dtfi, out num2, out ch)))
{
case TokenType.SEP_End:
dtok.dtt = DTT.NumEnd;
raw.AddNumber(dtok.num);
goto Label_0A1E;
case TokenType.SEP_Space:
dtok.dtt = DTT.NumSpace;
raw.AddNumber(dtok.num);
goto Label_0A1E;
case TokenType.SEP_Am:
case TokenType.SEP_Pm:
if (raw.timeMark == TM.NotSet)
{
raw.timeMark = (type2 == TokenType.SEP_Am) ? TM.AM : TM.PM;
dtok.dtt = DTT.NumAmpm;
raw.AddNumber(dtok.num);
}
else
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
}
goto Label_0A1E;
case TokenType.SEP_Time:
dtok.dtt = DTT.NumTimesep;
raw.AddNumber(dtok.num);
goto Label_0A1E;
case TokenType.SEP_YearSuff:
dtok.num = dtfi.Calendar.ToFourDigitYear(num);
dtok.dtt = DTT.NumDatesuff;
dtok.suffix = type2;
goto Label_0A1E;
case TokenType.SEP_Date:
dtok.dtt = DTT.NumDatesep;
raw.AddNumber(dtok.num);
goto Label_0A1E;
case TokenType.SEP_MonthSuff:
case TokenType.SEP_DaySuff:
dtok.dtt = DTT.NumDatesuff;
dtok.suffix = type2;
//.........这里部分代码省略.........
示例4: Lex
//.........这里部分代码省略.........
dtok.dtt = DTT.YearDateSep;
}
break;
case TokenType.SEP_YearSuff:
case TokenType.SEP_MonthSuff:
case TokenType.SEP_DaySuff:
dtok.dtt = DTT.NumDatesuff;
dtok.suffix = sep;
break;
case TokenType.SEP_HourSuff:
case TokenType.SEP_MinuteSuff:
case TokenType.SEP_SecondSuff:
dtok.dtt = DTT.NumTimesuff;
dtok.suffix = sep;
break;
default:
// Invalid separator after number number.
result.SetFailure(ParseFailureKind.Format, SR.Format_BadDateTime, null);
return false;
}
return true;
}
result.SetFailure(ParseFailureKind.Format, SR.Format_BadDateTime, null);
return false;
}
switch (sep = str.GetSeparatorToken(dtfi, out indexBeforeSeparator, out charBeforeSeparator))
{
//
// Note here we check if the numCount is less than three.
// When we have more than three numbers, it will be caught as error in the state machine.
//
case TokenType.SEP_End:
dtok.dtt = DTT.NumEnd;
raw.AddNumber(dtok.num);
break;
case TokenType.SEP_Am:
case TokenType.SEP_Pm:
if (raw.timeMark == TM.NotSet)
{
raw.timeMark = (sep == TokenType.SEP_Am ? TM.AM : TM.PM);
dtok.dtt = DTT.NumAmpm;
// Fix AM/PM parsing case, e.g. "1/10 5 AM"
if (dps == DS.D_NN)
{
if (!ProcessTerminaltState(DS.DX_NN, ref result, ref styles, ref raw, dtfi))
{
return false;
}
}
raw.AddNumber(dtok.num);
}
else
{
result.SetFailure(ParseFailureKind.Format, SR.Format_BadDateTime, null);
break;
}
if (dps == DS.T_NNt || dps == DS.T_Nt)
{
if (false == HandleTimeZone(ref str, ref result))
{
return false;
}
}
break;
case TokenType.SEP_Space:
示例5: Lex
//.........这里部分代码省略.........
case TokenType.SEP_YearSuff:
case TokenType.SEP_MonthSuff:
case TokenType.SEP_DaySuff:
dtok.dtt = DTT.NumDatesuff;
dtok.suffix = sep;
break;
case TokenType.SEP_HourSuff:
case TokenType.SEP_MinuteSuff:
case TokenType.SEP_SecondSuff:
dtok.dtt = DTT.NumTimesuff;
dtok.suffix = sep;
break;
default:
// Invalid separator after number number.
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
//
// Found the token already. Return now.
//
return true;
}
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
switch (sep = str.GetSeparatorToken(dtfi))
{
//
// Note here we check if the numCount is less than three.
// When we have more than three numbers, it will be caught as error in the state machine.
//
case TokenType.SEP_End:
dtok.dtt = DTT.NumEnd;
raw.AddNumber(dtok.num);
break;
case TokenType.SEP_Am:
case TokenType.SEP_Pm:
if (raw.timeMark == TM.NotSet) {
raw.timeMark = (sep == TokenType.SEP_Am ? TM.AM : TM.PM);
dtok.dtt = DTT.NumAmpm;
raw.AddNumber(dtok.num);
} else {
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
}
break;
case TokenType.SEP_Space:
dtok.dtt = DTT.NumSpace;
raw.AddNumber(dtok.num);
break;
case TokenType.SEP_Date:
dtok.dtt = DTT.NumDatesep;
raw.AddNumber(dtok.num);
break;
case TokenType.SEP_Time:
if ((result.flags & ParseFlags.TimeZoneUsed) == 0) {
dtok.dtt = DTT.NumTimesep;
raw.AddNumber(dtok.num);
} else {
// If we already got timezone, there should be no
// time separator again.
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
break;
case TokenType.SEP_YearSuff:
dtok.num = dtfi.Calendar.ToFourDigitYear(tokenValue);