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


C# Char.IsNameStart方法代码示例

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


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

示例1: NumberRest

        /// <summary>
        /// 4.4.13. Number-rest state
        /// </summary>
        CssToken NumberRest(Char current)
        {
            while (true)
            {
                if (current.IsDigit())
                    _stringBuffer.Append(current);
                else if (current.IsNameStart())
                {
                    var number = FlushBuffer();
                    _stringBuffer.Append(current);
                    return Dimension(Next, number);
                }
                else if (IsValidEscape(current))
                {
                    current = Next;
                    var number = FlushBuffer();
                    _stringBuffer.Append(ConsumeEscape(current));
                    return Dimension(Next, number);
                }
                else
                    break;

                current = Next;
            }

            switch (current)
            {
                case Specification.Dot:
                    current = Next;

                    if (current.IsDigit())
                    {
                        _stringBuffer.Append(Specification.Dot).Append(current);
                        return NumberFraction(Next);
                    }

                    Back();
                    return CssToken.Number(FlushBuffer());

                case '%':
                    return CssUnitToken.Percentage(FlushBuffer());

                case 'e':
                case 'E':
                    return NumberExponential(current);

                case Specification.Minus:
                    return NumberDash(current);

                default:
                    Back();
                    return CssToken.Number(FlushBuffer());
            }
        }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:57,代码来源:CssTokenizer.cs

示例2: IdentStart

        /// <summary>
        /// 4.4.9. Ident state
        /// </summary>
        CssToken IdentStart(Char current)
        {
            if (current == Specification.Minus)
            {
                current = Next;

                if (current.IsNameStart() || IsValidEscape(current))
                {
                    _stringBuffer.Append(Specification.Minus);
                    return IdentRest(current);
                }

                Back();
                return CssToken.Delim(Specification.Minus);
            }
            else if (current.IsNameStart())
            {
                _stringBuffer.Append(current);
                return IdentRest(Next);
            }
            else if (current == Specification.ReverseSolidus)
            {
                if (IsValidEscape(current))
                {
                    current = Next;
                    _stringBuffer.Append(ConsumeEscape(current));
                    return IdentRest(Next);
                }
            }

            return Data(current);
        }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:35,代码来源:CssTokenizer.cs

示例3: NumberDash

        /// <summary>
        /// Substate of several Number states.
        /// </summary>
        CssToken NumberDash(Char current)
        {
            current = Next;

            if (current.IsNameStart())
            {
                var number = FlushBuffer();
                _stringBuffer.Append(Specification.Minus).Append(current);
                return Dimension(Next, number);
            }
            else if (IsValidEscape(current))
            {
                current = Next;
                var number = FlushBuffer();
                _stringBuffer.Append(Specification.Minus).Append(ConsumeEscape(current));
                return Dimension(Next, number);
            }
            else
            {
                Back(2);
                return CssToken.Number(FlushBuffer());
            }
        }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:26,代码来源:CssTokenizer.cs

示例4: Data

        /// <summary>
        /// 4.4.1. Data state
        /// </summary>
        CssToken Data(Char current)
        {
            switch (current)
            {
                case Specification.LineFeed:
                case Specification.CarriageReturn:
                case Specification.Tab:
                case Specification.Space:
                    do { current = Next; }
                    while (current.IsSpaceCharacter());

                    if (_ignoreWs)
                        return Data(current);

                    Back();
                    return CssSpecialCharacter.Whitespace;

                case Specification.DoubleQuote:
                    return StringDQ(Next);

                case Specification.Num:
                    return HashStart(Next);

                case Specification.Dollar:
                    current = Next;

                    if (current == Specification.Equality)
                        return CssMatchToken.Suffix;

                    return CssToken.Delim(Previous);

                case Specification.SingleQuote:
                    return StringSQ(Next);

                case Specification.RoundBracketOpen:
                    return CssBracketToken.OpenRound;

                case Specification.RoundBracketClose:
                    return CssBracketToken.CloseRound;

                case Specification.Asterisk:
                    current = Next;

                    if (current == Specification.Equality)
                        return CssMatchToken.Substring;

                    return CssToken.Delim(Previous);

                case Specification.Plus:
                {
                    var c1 = Next;

                    if (c1 == Specification.EndOfFile)
                    {
                        Back();
                    }
                    else
                    {
                        var c2 = Next;
                        Back(2);

                        if (c1.IsDigit() || (c1 == Specification.Dot && c2.IsDigit()))
                            return NumberStart(current);
                    }

                    return CssToken.Delim(current);
                }

                case Specification.Comma:
                    return CssSpecialCharacter.Comma;

                case Specification.Dot:
                {
                    var c = Next;

                    if (c.IsDigit())
                        return NumberStart(Previous);

                    return CssToken.Delim(Previous);
                }

                case Specification.Minus:
                {
                    var c1 = Next;

                    if (c1 == Specification.EndOfFile)
                    {
                        Back();
                    }
                    else
                    {
                        var c2 = Next;
                        Back(2);

                        if (c1.IsDigit() || (c1 == Specification.Dot && c2.IsDigit()))
                            return NumberStart(current);
                        else if (c1.IsNameStart())
//.........这里部分代码省略.........
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:101,代码来源:CssTokenizer.cs

示例5: HashStart

 /// <summary>
 /// 4.4.4. Hash state
 /// </summary>
 CssToken HashStart(Char current)
 {
     if (current.IsNameStart())
     {
         _stringBuffer.Append(current);
         return HashRest(Next);
     }
     else if (IsValidEscape(current))
     {
         current = Next;
         _stringBuffer.Append(ConsumeEscape(current));
         return HashRest(Next);
     }
     else if (current == Specification.ReverseSolidus)
     {
         RaiseErrorOccurred(ErrorCode.InvalidCharacter);
         Back();
         return CssToken.Delim(Specification.Num);
     }
     else
     {
         Back();
         return CssToken.Delim(Specification.Num);
     }
 }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:28,代码来源:CssTokenizer.cs

示例6: Data

        /// <summary>
        /// 4.4.1. Data state
        /// </summary>
        CssToken Data(Char current)
        {
            _position = GetCurrentPosition();

            switch (current)
            {
                case Symbols.FormFeed:
                case Symbols.LineFeed:
                case Symbols.CarriageReturn:
                case Symbols.Tab:
                case Symbols.Space:
                    return NewWhitespace(current);

                case Symbols.DoubleQuote:
                    return StringDQ();

                case Symbols.Num:
                    return _valueMode ? ColorLiteral() : HashStart();

                case Symbols.Dollar:
                    current = GetNext();

                    if (current == Symbols.Equality)
                        return NewSuffix();

                    return NewDelimiter(GetPrevious());

                case Symbols.SingleQuote:
                    return StringSQ();

                case Symbols.RoundBracketOpen:
                    return NewOpenRound();

                case Symbols.RoundBracketClose:
                    return NewCloseRound();

                case Symbols.Asterisk:
                    current = GetNext();

                    if (current == Symbols.Equality)
                        return NewSubstring();

                    return NewDelimiter(GetPrevious());

                case Symbols.Plus:
                {
                    var c1 = GetNext();

                    if (c1 != Symbols.EndOfFile)
                    {
                        var c2 = GetNext();
                        Back(2);

                        if (c1.IsDigit() || (c1 == Symbols.Dot && c2.IsDigit()))
                            return NumberStart(current);
                    }
                    else
                        Back();
                        
                    return NewDelimiter(current);
                }

                case Symbols.Comma:
                    return NewComma();

                case Symbols.Dot:
                {
                    var c = GetNext();

                    if (c.IsDigit())
                        return NumberStart(GetPrevious());
                        
                    return NewDelimiter(GetPrevious());
                }

                case Symbols.Minus:
                {
                    var c1 = GetNext();

                    if (c1 != Symbols.EndOfFile)
                    {
                        var c2 = GetNext();
                        Back(2);

                        if (c1.IsDigit() || (c1 == Symbols.Dot && c2.IsDigit()))
                            return NumberStart(current);
                        else if (c1.IsNameStart())
                            return IdentStart(current);
                        else if (c1 == Symbols.ReverseSolidus && !c2.IsLineBreak() && c2 != Symbols.EndOfFile)
                            return IdentStart(current);
                        else if (c1 == Symbols.Minus && c2 == Symbols.GreaterThan)
                        {
                            Advance(2);
                            return NewCloseComment();
                        }
                    }
                    else
//.........这里部分代码省略.........
开发者ID:JBTech,项目名称:AngleSharp,代码行数:101,代码来源:CssTokenizer.cs

示例7: AtKeywordStart

        /// <summary>
        /// 4.4.7. At-keyword state
        /// </summary>
        CssToken AtKeywordStart(Char current)
        {
            if (current == Specification.Minus)
            {
                current = Next;

                if (current.IsNameStart() || IsValidEscape(current))
                {
                    _stringBuffer.Append(Specification.Minus);
                    return AtKeywordRest(current);
                }

                Back(2);
                return CssToken.Delim(Specification.At);
            }
            else if (current.IsNameStart())
            {
                _stringBuffer.Append(current);
                return AtKeywordRest(Next);
            }
            else if (IsValidEscape(current))
            {
                current = Next;
                _stringBuffer.Append(ConsumeEscape(current));
                return AtKeywordRest(Next);
            }
            else
            {
                Back();
                return CssToken.Delim(Specification.At);
            }
        }
开发者ID:jogibear9988,项目名称:AngleSharp,代码行数:35,代码来源:CssTokenizer.cs

示例8: IdentStart

        /// <summary>
        /// 4.4.9. Ident state
        /// </summary>
        CssToken IdentStart(Char current)
        {
            if (current == Specification.MINUS)
            {
                current = _src.Next;

                if (current.IsNameStart() || IsValidEscape(current))
                {
                    _stringBuffer.Append(Specification.MINUS);
                    return IdentRest(current);
                }

                _src.Back();
                return CssToken.Delim(Specification.MINUS);
            }
            else if (current.IsNameStart())
            {
                _stringBuffer.Append(current);
                return IdentRest(_src.Next);
            }
            else if (current == Specification.RSOLIDUS)
            {
                if (IsValidEscape(current))
                {
                    current = _src.Next;
                    _stringBuffer.Append(ConsumeEscape(current));
                    return IdentRest(_src.Next);
                }
            }

            return Data(current);
        }
开发者ID:rrsc,项目名称:AngleSharp,代码行数:35,代码来源:CssTokenizer.cs

示例9: IdentStart

        /// <summary>
        /// 4.4.9. Ident state
        /// </summary>
        CssToken IdentStart(Char current)
        {
            if (current == Symbols.Minus)
            {
                current = GetNext();

                if (current.IsNameStart() || IsValidEscape(current))
                {
                    _stringBuffer.Append(Symbols.Minus);
                    return IdentRest(current);
                }

                Back();
                return NewDelimiter(Symbols.Minus);
            }
            else if (current.IsNameStart())
            {
                _stringBuffer.Append(current);
                return IdentRest(GetNext());
            }
            else if (current == Symbols.ReverseSolidus)
            {
                if (IsValidEscape(current))
                {
                    current = GetNext();
                    _stringBuffer.Append(ConsumeEscape(current));
                    return IdentRest(GetNext());
                }
            }

            return Data(current);
        }
开发者ID:JBTech,项目名称:AngleSharp,代码行数:35,代码来源:CssTokenizer.cs

示例10: Data

        /// <summary>
        /// 4.4.1. Data state
        /// </summary>
        CssToken Data(Char current)
        {
            switch (current)
            {
                case Specification.LF:
                case Specification.CR:
                case Specification.TAB:
                case Specification.SPACE:
                    do { current = _src.Next; }
                    while (current.IsSpaceCharacter());

                    if (_ignoreWs)
                        return Data(current);

                    _src.Back();
                    return CssSpecialCharacter.Whitespace;

                case Specification.DQ:
                    return StringDQ(_src.Next);

                case Specification.NUM:
                    return HashStart(_src.Next);

                case Specification.DOLLAR:
                    current = _src.Next;

                    if (current == Specification.EQ)
                        return CssMatchToken.Suffix;

                    return CssToken.Delim(_src.Previous);

                case Specification.SQ:
                    return StringSQ(_src.Next);

                case Specification.RBO:
                    return CssBracketToken.OpenRound;

                case Specification.RBC:
                    return CssBracketToken.CloseRound;

                case Specification.ASTERISK:
                    current = _src.Next;

                    if (current == Specification.EQ)
                        return CssMatchToken.Substring;

                    return CssToken.Delim(_src.Previous);

                case Specification.PLUS:
                    {
                        var c1 = _src.Next;

                        if (c1 == Specification.EOF)
                        {
                            _src.Back();
                        }
                        else
                        {
                            var c2 = _src.Next;
                            _src.Back(2);

                            if (c1.IsDigit() || (c1 == Specification.DOT && c2.IsDigit()))
                                return NumberStart(current);
                        }

                        return CssToken.Delim(current);
                    }

                case Specification.COMMA:
                    return CssSpecialCharacter.Comma;

                case Specification.DOT:
                    {
                        var c = _src.Next;

                        if (c.IsDigit())
                            return NumberStart(_src.Previous);

                        return CssToken.Delim(_src.Previous);
                    }

                case Specification.MINUS:
                    {
                        var c1 = _src.Next;

                        if (c1 == Specification.EOF)
                        {
                            _src.Back();
                        }
                        else
                        {
                            var c2 = _src.Next;
                            _src.Back(2);

                            if (c1.IsDigit() || (c1 == Specification.DOT && c2.IsDigit()))
                                return NumberStart(current);
                            else if (c1.IsNameStart())
//.........这里部分代码省略.........
开发者ID:rrsc,项目名称:AngleSharp,代码行数:101,代码来源:CssTokenizer.cs

示例11: HashStart

 /// <summary>
 /// 4.4.4. Hash state
 /// </summary>
 CssToken HashStart(Char current)
 {
     if (current.IsNameStart())
     {
         _stringBuffer.Append(current);
         return HashRest(_src.Next);
     }
     else if (IsValidEscape(current))
     {
         current = _src.Next;
         _stringBuffer.Append(ConsumeEscape(current));
         return HashRest(_src.Next);
     }
     else if (current == Specification.RSOLIDUS)
     {
         RaiseErrorOccurred(ErrorCode.InvalidCharacter);
         _src.Back();
         return CssToken.Delim(Specification.NUM);
     }
     else
     {
         _src.Back();
         return CssToken.Delim(Specification.NUM);
     }
 }
开发者ID:rrsc,项目名称:AngleSharp,代码行数:28,代码来源:CssTokenizer.cs

示例12: TypeDeclarationChildren

        ElementDeclarationEntry TypeDeclarationChildren(Char c)
        {
            var entries = new List<ElementDeclarationEntry>();
            var connection = Specification.NULL;

            while (true)
            {
                if (entries.Count > 0)
                {
                    if (c != Specification.PIPE && c != Specification.COMMA)
                        throw new ArgumentException("Invalid content specification in element type declaration.");

                    if (entries.Count == 1)
                        connection = c;
                    else if (connection != c)
                        throw new ArgumentException("Invalid content specification in element type declaration.");

                    c = _src.Next;
                }

                while (c.IsSpaceCharacter())
                    c = _src.Next;

                if (c.IsNameStart())
                {
                    var name = TypeDeclarationName(c);
                    entries.Add(name);
                }
                else if (c == Specification.RBO)
                    entries.Add(TypeDeclarationChildren(_src.Next));
                else
                    throw new ArgumentException("Invalid content specification in element type declaration.");

                c = _src.Current;

                while (c.IsSpaceCharacter())
                    c = _src.Next;

                if (c == Specification.RBC)
                    break;
            }

            c = _src.Next;

            if (entries.Count == 1)
                return entries[0];
            else if (entries.Count == 0)
                throw new ArgumentException("Invalid content specification in element type declaration.");
            else if (connection == Specification.COMMA)
            {
                var sequence = new ElementSequenceDeclarationEntry();
                sequence.Sequence.AddRange(entries);
                sequence.Quantifier = TypeDeclarationQuantifier(c);
                return sequence;
            }

            var choice = new ElementChoiceDeclarationEntry();
            choice.Choice.AddRange(entries);
            choice.Quantifier = TypeDeclarationQuantifier(c);
            return choice;
        }
开发者ID:Rajbandi,项目名称:AngleSharp,代码行数:61,代码来源:DtdTokenizer.cs

示例13: AttributeDeclaration

        /// <summary>
        /// More http://www.w3.org/TR/REC-xml/#attdecls.
        /// </summary>
        /// <param name="c">The next input character.</param>
        DtdAttributeToken AttributeDeclaration(Char c)
        {
            var decl = new DtdAttributeToken();
            var canContinue = false;

            if (c.IsSpaceCharacter())
                canContinue = DeclarationNameBefore(_src.Next, decl);
            else if (c == Specification.EOF)
                throw new ArgumentException("The document ended unexpectedly.");
            else
            {
                RaiseErrorOccurred(ErrorCode.UndefinedMarkupDeclaration);
                canContinue = DeclarationNameBefore(c, decl);
            }

            c = _src.Current;

            if (canContinue)
            {
                while (true)
                {
                    while (c.IsSpaceCharacter())
                        c = _src.Next;

                    if (c.IsNameStart())
                    {
                        _stringBuffer.Clear();
                        decl.Attributes.Add(AttributeDeclarationName(c));
                        c = _src.Current;
                        continue;
                    }

                    break;
                }
            }

            return AttributeDeclarationAfter(c, decl);
        }
开发者ID:Rajbandi,项目名称:AngleSharp,代码行数:42,代码来源:DtdTokenizer.cs

示例14: EntityDeclarationAfter

        DtdToken EntityDeclarationAfter(Char c, DtdEntityToken decl)
        {
            while (c.IsSpaceCharacter())
                c = _src.Next;

            if (c == Specification.EOF)
                throw new ArgumentException("The document ended unexpectedly.");
            else if (c == Specification.GT)
                return decl;
            else if (decl.IsExtern && String.IsNullOrEmpty(decl.ExternNotation))
            {
                if (_src.ContinuesWith("NDATA"))
                {
                    _src.Advance(4);
                    c = _src.Next;

                    while (c.IsSpaceCharacter())
                        c = _src.Next;

                    if (c.IsNameStart())
                    {
                        _stringBuffer.Clear();

                        do
                        {
                            _stringBuffer.Append(c);
                            c = _src.Next;
                        }
                        while (c.IsName());

                        decl.ExternNotation = _stringBuffer.ToString();
                        return EntityDeclarationAfter(c, decl);
                    }
                }
            }

            throw new ArgumentException("Declaration invalid.");
        }
开发者ID:Rajbandi,项目名称:AngleSharp,代码行数:38,代码来源:DtdTokenizer.cs

示例15: TypeDeclarationMixed

        ElementMixedDeclarationEntry TypeDeclarationMixed(Char c)
        {
            var entry = new ElementMixedDeclarationEntry();

            while (true)
            {
                while (c.IsSpaceCharacter())
                    c = _src.Next;

                if (c == Specification.RBC)
                {
                    c = _src.Next;

                    if (c == Specification.ASTERISK)
                    {
                        entry.Quantifier = ElementDeclarationEntry.ElementQuantifier.ZeroOrMore;
                        _src.Advance();
                        return entry;
                    }

                    if (entry.Names.Count > 0)
                        RaiseErrorOccurred(ErrorCode.QuantifierMissing);

                    break;
                }
                else if (c == Specification.PIPE)
                {
                    c = _src.Next;

                    while (c.IsSpaceCharacter())
                        c = _src.Next;

                    _stringBuffer.Clear();

                    if (c.IsNameStart())
                    {
                        _stringBuffer.Append(c);

                        while ((c = _src.Next).IsName())
                            _stringBuffer.Append(c);

                        entry.Names.Add(_stringBuffer.ToString());
                    }
                    else
                        throw new ArgumentException("Invalid content specification in element type declaration.");
                }
            }

            return entry;
        }
开发者ID:Rajbandi,项目名称:AngleSharp,代码行数:50,代码来源:DtdTokenizer.cs


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