当前位置: 首页>>代码示例>>C#>>正文


C# DateTimeFormatInfo.Tokenize方法代码示例

本文整理汇总了C#中DateTimeFormatInfo.Tokenize方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeFormatInfo.Tokenize方法的具体用法?C# DateTimeFormatInfo.Tokenize怎么用?C# DateTimeFormatInfo.Tokenize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTimeFormatInfo的用法示例。


在下文中一共展示了DateTimeFormatInfo.Tokenize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSeparatorToken

 [System.Security.SecurityCritical]  // auto-generated
 internal TokenType GetSeparatorToken(DateTimeFormatInfo dtfi, out int indexBeforeSeparator, out char charBeforeSeparator) {
     indexBeforeSeparator = Index;
     charBeforeSeparator = m_current;
     TokenType tokenType;
     if (!SkipWhiteSpaceCurrent()) {
         // Reach the end of the string.
         return (TokenType.SEP_End);
     }
     if (!DateTimeParse.IsDigit(m_current)) {
         // Not a digit.  Tokenize it.
         int tokenValue;
         bool found = dtfi.Tokenize(TokenType.SeparatorTokenMask, out tokenType, out tokenValue, ref this);
         if (!found) {
             tokenType = TokenType.SEP_Space;
         }
     } else {
         // Do nothing here.  If we see a number, it will not be a separator. There is no need wasting time trying to find the
         // separator token.
         tokenType = TokenType.SEP_Space;
     }
     return (tokenType);
 }
开发者ID:stormleoxia,项目名称:referencesource,代码行数:23,代码来源:datetimeparse.cs

示例2: GetRegularToken

        [System.Security.SecurityCritical]  // auto-generated
        internal void GetRegularToken(out TokenType tokenType, out int tokenValue, DateTimeFormatInfo dtfi) {
            tokenValue = 0;
            if (Index >= len) {
                tokenType = TokenType.EndOfString;
                return;
            }

            tokenType = TokenType.UnknownToken;

Start:
            if (DateTimeParse.IsDigit(m_current)) {
                // This is a digit.
                tokenValue = m_current - '0';
                int value;
                int start = Index;

                //
                // Collect other digits.
                //
                while (++Index < len)
                {
                    m_current = Value[Index];
                    value = m_current - '0';
                    if (value >= 0 && value <= 9) {
                        tokenValue = tokenValue * 10 + value;
                    } else {
                        break;
                    }
                }
                if (Index - start > DateTimeParse.MaxDateTimeNumberDigits) {
                    tokenType = TokenType.NumberToken;
                    tokenValue = -1;
                } else if (Index - start < 3) {
                    tokenType = TokenType.NumberToken;
                } else {
                    // If there are more than 3 digits, assume that it's a year value.
                    tokenType = TokenType.YearNumberToken;
                }
                if (m_checkDigitToken)
                {
                    int save = Index;
                    char saveCh = m_current;
                    // Re-scan using the staring Index to see if this is a token.
                    Index = start;  // To include the first digit.
                    m_current = Value[Index];
                    TokenType tempType;
                    int tempValue;
                    // This DTFI has tokens starting with digits.
                    // E.g. mn-MN has month name like "\x0031\x00a0\x0434\x04af\x0433\x044d\x044d\x0440\x00a0\x0441\x0430\x0440"
                    if (dtfi.Tokenize(TokenType.RegularTokenMask, out tempType, out tempValue, ref this))
                    {
                        tokenType = tempType;
                        tokenValue = tempValue;
                        // This is a token, so the Index has been advanced propertly in DTFI.Tokenizer().
                    } else
                    {
                        // Use the number token value.
                        // Restore the index.
                        Index = save;
                        m_current = saveCh;
                    }
                    
                } 
                
            } else if (Char.IsWhiteSpace( m_current)) {
                // Just skip to the next character.
                while (++Index < len) {
                    m_current = Value[Index];
                    if (!(Char.IsWhiteSpace(m_current))) {
                        goto Start;
                    }
                }
                // We have reached the end of string.
                tokenType = TokenType.EndOfString;
            } else {
                dtfi.Tokenize(TokenType.RegularTokenMask, out tokenType, out tokenValue, ref this);
            }
        }
开发者ID:stormleoxia,项目名称:referencesource,代码行数:79,代码来源:datetimeparse.cs


注:本文中的DateTimeFormatInfo.Tokenize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。