本文整理汇总了C#中System.__DTString.GetSeparatorToken方法的典型用法代码示例。如果您正苦于以下问题:C# __DTString.GetSeparatorToken方法的具体用法?C# __DTString.GetSeparatorToken怎么用?C# __DTString.GetSeparatorToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.__DTString
的用法示例。
在下文中一共展示了__DTString.GetSeparatorToken方法的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
[System.Security.SecuritySafeCritical] // auto-generated
private static Boolean Lex(DS dps, ref __DTString str, ref DateTimeToken dtok, ref DateTimeRawInfo raw, ref DateTimeResult result, ref DateTimeFormatInfo dtfi, DateTimeStyles styles)
{
TokenType tokenType;
int tokenValue;
int indexBeforeSeparator;
char charBeforeSeparator;
TokenType sep;
dtok.dtt = DTT.Unk; // Assume the token is unkown.
str.GetRegularToken(out tokenType, out tokenValue, dtfi);
#if _LOGGING
// Builds with _LOGGING defined (x86dbg, amd64chk, etc) support tracing
// Set the following internal-only/unsupported environment variables to enable DateTime tracing to the console:
//
// COMPlus_LogEnable=1
// COMPlus_LogToConsole=1
// COMPlus_LogLevel=9
// COMPlus_ManagedLogFacility=0x00001000
if (_tracingEnabled) {
BCLDebug.Trace("DATETIME", "[DATETIME] Lex({0})\tpos:{1}({2}), {3}, DS.{4}", Hex(str.Value),
str.Index, Hex(str.m_current), tokenType, dps);
}
#endif // _LOGGING
// Look at the regular token.
switch (tokenType) {
case TokenType.NumberToken:
case TokenType.YearNumberToken:
if (raw.numCount == 3 || tokenValue == -1) {
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
LexTraceExit("0010", dps);
return false;
}
//
// This is a digit.
//
// If the previous parsing state is DS.T_NNt (like 12:01), and we got another number,
// so we will have a terminal state DS.TX_NNN (like 12:01:02).
// If the previous parsing state is DS.T_Nt (like 12:), and we got another number,
// so we will have a terminal state DS.TX_NN (like 12:01).
//
// Look ahead to see if the following character is a decimal point or timezone offset.
// This enables us to parse time in the forms of:
// "11:22:33.1234" or "11:22:33-08".
if (dps == DS.T_NNt) {
if ((str.Index < str.len - 1)) {
char nextCh = str.Value[str.Index];
if (nextCh == '.') {
// While ParseFraction can fail, it just means that there were no digits after
// the dot. In this case ParseFraction just removes the dot. This is actually
// valid for cultures like Albanian, that join the time marker to the time with
// with a dot: e.g. "9:03.MD"
ParseFraction(ref str, out raw.fraction);
}
}
}
if (dps == DS.T_NNt || dps == DS.T_Nt) {
if ((str.Index < str.len - 1)) {
if (false == HandleTimeZone(ref str, ref result))
{
LexTraceExit("0020 (value like \"12:01\" or \"12:\" followed by a non-TZ number", dps);
return false;
}
}
}
dtok.num = tokenValue;
if (tokenType == TokenType.YearNumberToken)
{
if (raw.year == -1)
{
raw.year = tokenValue;
//
// If we have number which has 3 or more digits (like "001" or "0001"),
// we assume this number is a year. Save the currnet raw.numCount in
// raw.year.
//
switch (sep = str.GetSeparatorToken(dtfi, out indexBeforeSeparator, out charBeforeSeparator)) {
case TokenType.SEP_End:
dtok.dtt = DTT.YearEnd;
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.YearSpace;
} else {
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
LexTraceExit("0030 (TM.AM/TM.PM Happened more than 1x)", dps);
}
break;
case TokenType.SEP_Space:
dtok.dtt = DTT.YearSpace;
break;
case TokenType.SEP_Date:
dtok.dtt = DTT.YearDateSep;
//.........这里部分代码省略.........
示例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
//
// 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 Boolean Lex(
DS dps, ref __DTString str, ref DateTimeToken dtok, ref DateTimeRawInfo raw, ref DateTimeResult result, ref DateTimeFormatInfo dtfi, DateTimeStyles styles)
{
TokenType tokenType;
int tokenValue;
int indexBeforeSeparator;
char charBeforeSeparator;
TokenType sep;
dtok.dtt = DTT.Unk; // Assume the token is unkown.
str.GetRegularToken(out tokenType, out tokenValue, dtfi);
// Look at the regular token.
switch (tokenType)
{
case TokenType.NumberToken:
case TokenType.YearNumberToken:
if (raw.numCount == 3 || tokenValue == -1)
{
result.SetFailure(ParseFailureKind.Format, SR.Format_BadDateTime, null);
return false;
}
//
// This is a digit.
//
// If the previous parsing state is DS.T_NNt (like 12:01), and we got another number,
// so we will have a terminal state DS.TX_NNN (like 12:01:02).
// If the previous parsing state is DS.T_Nt (like 12:), and we got another number,
// so we will have a terminal state DS.TX_NN (like 12:01).
//
// Look ahead to see if the following character is a decimal point or timezone offset.
// This enables us to parse time in the forms of:
// "11:22:33.1234" or "11:22:33-08".
if (dps == DS.T_NNt)
{
if ((str.Index < str.len - 1))
{
char nextCh = str.Value[str.Index];
if (nextCh == '.')
{
// While ParseFraction can fail, it just means that there were no digits after
// the dot. In this case ParseFraction just removes the dot. This is actually
// valid for cultures like Albanian, that join the time marker to the time with
// with a dot: e.g. "9:03.MD"
ParseFraction(ref str, out raw.fraction);
}
}
}
if (dps == DS.T_NNt || dps == DS.T_Nt)
{
if ((str.Index < str.len - 1))
{
if (false == HandleTimeZone(ref str, ref result))
{
return false;
}
}
}
dtok.num = tokenValue;
if (tokenType == TokenType.YearNumberToken)
{
if (raw.year == -1)
{
raw.year = tokenValue;
//
// If we have number which has 3 or more digits (like "001" or "0001"),
// we assume this number is a year. Save the currnet raw.numCount in
// raw.year.
//
switch (sep = str.GetSeparatorToken(dtfi, out indexBeforeSeparator, out charBeforeSeparator))
{
case TokenType.SEP_End:
dtok.dtt = DTT.YearEnd;
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.YearSpace;
}
else
{
result.SetFailure(ParseFailureKind.Format, SR.Format_BadDateTime, null);
}
break;
case TokenType.SEP_Space:
dtok.dtt = DTT.YearSpace;
break;
case TokenType.SEP_Date:
dtok.dtt = DTT.YearDateSep;
break;
case TokenType.SEP_Time:
//.........这里部分代码省略.........
示例5: 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 Boolean Lex(
DS dps, ref __DTString str, ref DateTimeToken dtok, ref DateTimeRawInfo raw, ref DateTimeResult result, ref DateTimeFormatInfo dtfi) {
TokenType tokenType;
int tokenValue;
TokenType sep;
dtok.dtt = DTT.Unk; // Assume the token is unkown.
str.GetRegularToken(out tokenType, out tokenValue, dtfi);
// Look at the regular token.
switch (tokenType) {
case TokenType.NumberToken:
case TokenType.YearNumberToken:
if (raw.numCount == 3 || tokenValue == -1) {
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
//
// This is a digit.
//
// If the previous parsing state is DS.T_NNt (like 12:01), and we got another number,
// so we will have a terminal state DS.TX_NNN (like 12:01:02).
// If the previous parsing state is DS.T_Nt (like 12:), and we got another number,
// so we will have a terminal state DS.TX_NN (like 12:01).
//
// Look ahead to see if the following character is a decimal point or timezone offset.
// This enables us to parse time in the forms of:
// "11:22:33.1234" or "11:22:33-08".
if (dps == DS.T_NNt) {
if ((str.Index < str.len - 1)) {
char nextCh = str.Value[str.Index];
if (nextCh == '.') {
// While ParseFraction can fail, it just means that there were no digits after
// the dot. In this case ParseFraction just swallows the dot. This is actually
// valid for cultures like Albanian, that join the time marker to the time with
// with a dot: e.g. "9:03.MD"
ParseFraction(ref str, out raw.fraction);
}
}
}
if (dps == DS.T_NNt || dps == DS.T_Nt) {
if ((str.Index < str.len - 1)) {
char nextCh = str.Value[str.Index];
// Skip whitespace, but don't update the index unless we find a time zone marker
int whitespaceCount = 0;
while (Char.IsWhiteSpace(nextCh) && str.Index + whitespaceCount < str.len - 1) {
whitespaceCount++;
nextCh = str.Value[str.Index + whitespaceCount];
}
if (nextCh == '+' || nextCh == '-') {
str.Index += whitespaceCount;
if ((result.flags & ParseFlags.TimeZoneUsed) != 0) {
// Should not have two timezone offsets.
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;
}
}
}
}
dtok.num = tokenValue;
if (tokenType == TokenType.YearNumberToken)
{
if (raw.year == -1)
{
raw.year = tokenValue;
//
// If we have number which has 3 or more digits (like "001" or "0001"),
// we assume this number is a year. Save the currnet raw.numCount in
// raw.year.
//
switch (sep = str.GetSeparatorToken(dtfi)) {
case TokenType.SEP_End:
dtok.dtt = DTT.YearEnd;
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.YearSpace;
} else {
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
}
break;
case TokenType.SEP_Space:
dtok.dtt = DTT.YearSpace;
break;
case TokenType.SEP_Date:
dtok.dtt = DTT.YearDateSep;
//.........这里部分代码省略.........