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


C# __DTString.Advance方法代码示例

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


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

示例1: Tokenize

        [System.Security.SecurityCritical]  // auto-generated
        internal bool Tokenize(TokenType TokenMask, out TokenType tokenType, out int tokenValue, ref __DTString str) {
            tokenType = TokenType.UnknownToken;
            tokenValue = 0;

            TokenHashValue value;
            Contract.Assert(str.Index < str.Value.Length, "DateTimeFormatInfo.Tokenize(): start < value.Length");

            char ch = str.m_current;
            bool isLetter = Char.IsLetter(ch);
            if (isLetter) {
                ch = Char.ToLower(ch, this.Culture);
                if (IsHebrewChar(ch) && TokenMask == TokenType.RegularTokenMask) {
                    bool badFormat;
                    if (TryParseHebrewNumber(ref str, out badFormat, out tokenValue)) {
                        if (badFormat) {
                            tokenType = TokenType.UnknownToken;
                            return (false);
                        }
                        // This is a Hebrew number.
                        // Do nothing here.  TryParseHebrewNumber() will update token accordingly.
                        tokenType = TokenType.HebrewNumber;
                        return (true);
                    }
                }
            }


            int hashcode = ch % TOKEN_HASH_SIZE;
            int hashProbe = 1 + ch % SECOND_PRIME;
            int remaining = str.len - str.Index;
            int i = 0;

            TokenHashValue[] hashTable = m_dtfiTokenHash;
            if (hashTable == null) {
                hashTable = CreateTokenHashTable();
            }
            do {
                value = hashTable[hashcode];
                if (value == null) {
                    // Not found.
                    break;
                }
                // Check this value has the right category (regular token or separator token) that we are looking for.
                if (((int)value.tokenType & (int)TokenMask) > 0 && value.tokenString.Length <= remaining) {
                    if (String.Compare(str.Value, str.Index, value.tokenString, 0, value.tokenString.Length, this.Culture, CompareOptions.IgnoreCase)==0) {
                        if (isLetter) {
                            // If this token starts with a letter, make sure that we won't allow partial match.  So you can't tokenize "MarchWed" separately.
                            int nextCharIndex;
                            if ((nextCharIndex = str.Index + value.tokenString.Length) < str.len) {
                                // Check word boundary.  The next character should NOT be a letter.
                                char nextCh = str.Value[nextCharIndex];
                                if (Char.IsLetter(nextCh)) {
                                    return (false);
                                }
                            }
                        }
                        tokenType = value.tokenType & TokenMask;
                        tokenValue = value.tokenValue;
                        str.Advance(value.tokenString.Length);
                        return (true);
                    }  else if (value.tokenType == TokenType.MonthToken && HasSpacesInMonthNames) {
                        // For month token, we will match the month names which have spaces.
                        int matchStrLen = 0;
                        if (str.MatchSpecifiedWords(value.tokenString, true, ref matchStrLen)) {
                            tokenType = value.tokenType & TokenMask;
                            tokenValue = value.tokenValue;
                            str.Advance(matchStrLen);
                            return (true);
                        }
                    }  else if (value.tokenType == TokenType.DayOfWeekToken && HasSpacesInDayNames) {
                        // For month token, we will match the month names which have spaces.
                        int matchStrLen = 0;
                        if (str.MatchSpecifiedWords(value.tokenString, true, ref matchStrLen)) {
                            tokenType = value.tokenType & TokenMask;
                            tokenValue = value.tokenValue;
                            str.Advance(matchStrLen);
                            return (true);
                        }
                    }
                }
                i++;
                hashcode += hashProbe;
                if (hashcode >= TOKEN_HASH_SIZE) hashcode -= TOKEN_HASH_SIZE;
            }while (i < TOKEN_HASH_SIZE);

            return (false);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:88,代码来源:DateTimeFormatInfo.cs

示例2: TryParseHebrewNumber

        ////////////////////////////////////////////////////////////////////////
        //
        // Actions:
        // Try to parse the current word to see if it is a Hebrew number.
        // Tokens will be updated accordingly.
        // This is called by the Lexer of DateTime.Parse().
        //
        // Unlike most of the functions in this class, the return value indicates
        // whether or not it started to parse. The badFormat parameter indicates
        // if parsing began, but the format was bad.
        //
        ////////////////////////////////////////////////////////////////////////

        private static bool TryParseHebrewNumber(
            ref __DTString str,
            out Boolean badFormat,
            out int number)  {

            number = -1;
            badFormat = false;

            int i = str.Index;
            if (!HebrewNumber.IsDigit(str.Value[i])) {
                // If the current character is not a Hebrew digit, just return false.
                // There is no chance that we can parse a valid Hebrew number from here.
                return (false);
            }
            // The current character is a Hebrew digit.  Try to parse this word as a Hebrew number.
            HebrewNumberParsingContext context = new HebrewNumberParsingContext(0);
            HebrewNumberParsingState state;

            do {
                state = HebrewNumber.ParseByChar(str.Value[i++], ref context);
                switch (state) {
                    case HebrewNumberParsingState.InvalidHebrewNumber:    // Not a valid Hebrew number.
                    case HebrewNumberParsingState.NotHebrewDigit:         // The current character is not a Hebrew digit character.
                        // Break out so that we don't continue to try parse this as a Hebrew number.
                        return (false);
                }
            } while (i < str.Value.Length && (state != HebrewNumberParsingState.FoundEndOfHebrewNumber));

            // When we are here, we are either at the end of the string, or we find a valid Hebrew number.
            Contract.Assert(state == HebrewNumberParsingState.ContinueParsing || state == HebrewNumberParsingState.FoundEndOfHebrewNumber,
                "Invalid returned state from HebrewNumber.ParseByChar()");

            if (state != HebrewNumberParsingState.FoundEndOfHebrewNumber) {
                // We reach end of the string but we can't find a terminal state in parsing Hebrew number.
                return (false);
            }

            // We have found a valid Hebrew number.  Update the index.
            str.Advance(i - str.Index);

            // Get the final Hebrew number value from the HebrewNumberParsingContext.
            number = context.result;

            return (true);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:58,代码来源:DateTimeFormatInfo.cs

示例3: Tokenize

 internal bool Tokenize(TokenType TokenMask, out TokenType tokenType, out int tokenValue, ref __DTString str)
 {
     tokenType = TokenType.UnknownToken;
       tokenValue = 0;
       char ch = str.m_current;
       bool flag = char.IsLetter(ch);
       if (flag)
       {
     ch = char.ToLower(ch, this.Culture);
     bool badFormat;
     if (DateTimeFormatInfo.IsHebrewChar(ch) && TokenMask == TokenType.RegularTokenMask && DateTimeFormatInfo.TryParseHebrewNumber(ref str, out badFormat, out tokenValue))
     {
       if (badFormat)
       {
     tokenType = TokenType.UnknownToken;
     return false;
       }
       else
       {
     tokenType = TokenType.HebrewNumber;
     return true;
       }
     }
       }
       int index1 = (int) ch % 199;
       int num1 = 1 + (int) ch % 197;
       int num2 = str.len - str.Index;
       int num3 = 0;
       TokenHashValue[] tokenHashValueArray = this.m_dtfiTokenHash ?? this.CreateTokenHashTable();
       do
       {
     TokenHashValue tokenHashValue = tokenHashValueArray[index1];
     if (tokenHashValue != null)
     {
       if ((tokenHashValue.tokenType & TokenMask) > (TokenType) 0 && tokenHashValue.tokenString.Length <= num2)
       {
     if (string.Compare(str.Value, str.Index, tokenHashValue.tokenString, 0, tokenHashValue.tokenString.Length, this.Culture, CompareOptions.IgnoreCase) == 0)
     {
       int index2;
       if (flag && (index2 = str.Index + tokenHashValue.tokenString.Length) < str.len && char.IsLetter(str.Value[index2]))
         return false;
       tokenType = tokenHashValue.tokenType & TokenMask;
       tokenValue = tokenHashValue.tokenValue;
       str.Advance(tokenHashValue.tokenString.Length);
       return true;
     }
     else if (tokenHashValue.tokenType == TokenType.MonthToken && this.HasSpacesInMonthNames)
     {
       int matchLength = 0;
       if (str.MatchSpecifiedWords(tokenHashValue.tokenString, true, ref matchLength))
       {
         tokenType = tokenHashValue.tokenType & TokenMask;
         tokenValue = tokenHashValue.tokenValue;
         str.Advance(matchLength);
         return true;
       }
     }
     else if (tokenHashValue.tokenType == TokenType.DayOfWeekToken && this.HasSpacesInDayNames)
     {
       int matchLength = 0;
       if (str.MatchSpecifiedWords(tokenHashValue.tokenString, true, ref matchLength))
       {
         tokenType = tokenHashValue.tokenType & TokenMask;
         tokenValue = tokenHashValue.tokenValue;
         str.Advance(matchLength);
         return true;
       }
     }
       }
       ++num3;
       index1 += num1;
       if (index1 >= 199)
     index1 -= 199;
     }
     else
       break;
       }
       while (num3 < 199);
       return false;
 }
开发者ID:korifey,项目名称:hackathon-Ideaphone,代码行数:80,代码来源:DateTimeFormatInfo.cs

示例4: TryParseHebrewNumber

 private static bool TryParseHebrewNumber(ref __DTString str, out bool badFormat, out int number)
 {
     number = -1;
       badFormat = false;
       int index = str.Index;
       if (!HebrewNumber.IsDigit(str.Value[index]))
     return false;
       HebrewNumberParsingContext context = new HebrewNumberParsingContext(0);
       HebrewNumberParsingState numberParsingState;
       do
       {
     numberParsingState = HebrewNumber.ParseByChar(str.Value[index++], ref context);
     switch (numberParsingState)
     {
       case HebrewNumberParsingState.InvalidHebrewNumber:
       case HebrewNumberParsingState.NotHebrewDigit:
     return false;
       default:
     continue;
     }
       }
       while (index < str.Value.Length && numberParsingState != HebrewNumberParsingState.FoundEndOfHebrewNumber);
       if (numberParsingState != HebrewNumberParsingState.FoundEndOfHebrewNumber)
     return false;
       str.Advance(index - str.Index);
       number = context.result;
       return true;
 }
开发者ID:korifey,项目名称:hackathon-Ideaphone,代码行数:28,代码来源:DateTimeFormatInfo.cs

示例5: Tokenize

 internal bool Tokenize(TokenType TokenMask, out TokenType tokenType, out int tokenValue, ref __DTString str)
 {
     tokenType = TokenType.UnknownToken;
     tokenValue = 0;
     char current = str.m_current;
     bool flag = char.IsLetter(current);
     if (flag)
     {
         bool flag2;
         current = char.ToLower(current, this.Culture);
         if ((IsHebrewChar(current) && (TokenMask == TokenType.RegularTokenMask)) && TryParseHebrewNumber(ref str, out flag2, out tokenValue))
         {
             if (flag2)
             {
                 tokenType = TokenType.UnknownToken;
                 return false;
             }
             tokenType = TokenType.HebrewNumber;
             return true;
         }
     }
     int index = current % '\x00c7';
     int num2 = 1 + (current % '\x00c5');
     int num3 = str.len - str.Index;
     int num4 = 0;
     TokenHashValue[] dtfiTokenHash = this.m_dtfiTokenHash;
     if (dtfiTokenHash == null)
     {
         dtfiTokenHash = this.CreateTokenHashTable();
     }
     do
     {
         TokenHashValue value2 = dtfiTokenHash[index];
         if (value2 == null)
         {
             break;
         }
         if (((value2.tokenType & TokenMask) > ((TokenType) 0)) && (value2.tokenString.Length <= num3))
         {
             if (string.Compare(str.Value, str.Index, value2.tokenString, 0, value2.tokenString.Length, this.Culture, CompareOptions.IgnoreCase) == 0)
             {
                 int num5;
                 if (flag && ((num5 = str.Index + value2.tokenString.Length) < str.len))
                 {
                     char c = str.Value[num5];
                     if (char.IsLetter(c))
                     {
                         return false;
                     }
                 }
                 tokenType = value2.tokenType & TokenMask;
                 tokenValue = value2.tokenValue;
                 str.Advance(value2.tokenString.Length);
                 return true;
             }
             if ((value2.tokenType == TokenType.MonthToken) && this.HasSpacesInMonthNames)
             {
                 int matchLength = 0;
                 if (str.MatchSpecifiedWords(value2.tokenString, true, ref matchLength))
                 {
                     tokenType = value2.tokenType & TokenMask;
                     tokenValue = value2.tokenValue;
                     str.Advance(matchLength);
                     return true;
                 }
             }
             else if ((value2.tokenType == TokenType.DayOfWeekToken) && this.HasSpacesInDayNames)
             {
                 int num7 = 0;
                 if (str.MatchSpecifiedWords(value2.tokenString, true, ref num7))
                 {
                     tokenType = value2.tokenType & TokenMask;
                     tokenValue = value2.tokenValue;
                     str.Advance(num7);
                     return true;
                 }
             }
         }
         num4++;
         index += num2;
         if (index >= 0xc7)
         {
             index -= 0xc7;
         }
     }
     while (num4 < 0xc7);
     return false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:88,代码来源:DateTimeFormatInfo.cs


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