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


C# ParsingFunction类代码示例

本文整理汇总了C#中ParsingFunction的典型用法代码示例。如果您正苦于以下问题:C# ParsingFunction类的具体用法?C# ParsingFunction怎么用?C# ParsingFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ParseAttributes

        // Reads the attributes
        private void ParseAttributes()
        {
            int pos = _ps.charPos;
            char[] chars = _ps.chars;
            NodeData attr = null;

            Debug.Assert(_attrCount == 0);

            for (;;)
            {
                // eat whitespaces
                int lineNoDelta = 0;
                char tmpch0;
                unsafe
                {
                    while (_xmlCharType.IsWhiteSpace(tmpch0 = chars[pos]))
                    {
                        if (tmpch0 == (char)0xA)
                        {
                            OnNewLine(pos + 1);
                            lineNoDelta++;
                        }
                        else if (tmpch0 == (char)0xD)
                        {
                            if (chars[pos + 1] == (char)0xA)
                            {
                                OnNewLine(pos + 2);
                                lineNoDelta++;
                                pos++;
                            }
                            else if (pos + 1 != _ps.charsUsed)
                            {
                                OnNewLine(pos + 1);
                                lineNoDelta++;
                            }
                            else
                            {
                                _ps.charPos = pos;
                                goto ReadData;
                            }
                        }
                        pos++;
                    }
                }

                char tmpch1;
                int startNameCharSize = 0;

                unsafe
                {
                    if (_xmlCharType.IsStartNCNameSingleChar(tmpch1 = chars[pos]))
                    {
                        startNameCharSize = 1;
                    }
#if XML10_FIFTH_EDITION
                    else if (pos + 1 < ps.charsUsed && xmlCharType.IsNCNameSurrogateChar(chars[pos + 1], tmpch1))
                    {
                        startNameCharSize = 2;
                    }
#endif
                }

                if (startNameCharSize == 0)
                {
                    // element end
                    if (tmpch1 == '>')
                    {
                        Debug.Assert(_curNode.type == XmlNodeType.Element);
                        _ps.charPos = pos + 1;
                        _parsingFunction = ParsingFunction.MoveToElementContent;
                        goto End;
                    }
                    // empty element end
                    else if (tmpch1 == '/')
                    {
                        Debug.Assert(_curNode.type == XmlNodeType.Element);
                        if (pos + 1 == _ps.charsUsed)
                        {
                            goto ReadData;
                        }
                        if (chars[pos + 1] == '>')
                        {
                            _ps.charPos = pos + 2;
                            _curNode.IsEmptyElement = true;
                            _nextParsingFunction = _parsingFunction;
                            _parsingFunction = ParsingFunction.PopEmptyElementContext;
                            goto End;
                        }
                        else
                        {
                            ThrowUnexpectedToken(pos + 1, ">");
                        }
                    }
                    else if (pos == _ps.charsUsed)
                    {
                        goto ReadData;
                    }
                    else if (tmpch1 != ':' || _supportNamespaces)
                    {
//.........这里部分代码省略.........
开发者ID:chcosta,项目名称:corefx,代码行数:101,代码来源:XmlTextReaderImpl.cs

示例2: ReadElementContentAsBinHex

        public override  int  ReadElementContentAsBinHex( byte[] buffer, int index, int count ) {
            if ( ReadState != ReadState.Interactive ) {
                return 0;
            }

            // init ReadChunkHelper when called first time
            if ( parsingFunction != ParsingFunction.InReadBinaryContent ) {
                readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset( readBinaryHelper, outerReader );
            }

            // set parsingFunction to Read state in order to have a normal Read() behavior when called from readBinaryHelper
            parsingFunction = ParsingFunction.Read;

            // call to the helper
            int readCount = readBinaryHelper.ReadElementContentAsBinHex( buffer, index, count );

            // setup parsingFunction 
            parsingFunction = ParsingFunction.InReadBinaryContent;
            return readCount;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:20,代码来源:XmlValidatingReaderImpl.cs

示例3: ProcessCoreReaderEvent

//
// Internal methods for validators, DOM, XPathDocument etc.
//
        private void ProcessCoreReaderEvent() {
            switch ( coreReader.NodeType ) {
                case XmlNodeType.Whitespace:
                    if ( coreReader.Depth > 0 || coreReaderImpl.FragmentType != XmlNodeType.Document ) {
                        if ( validator.PreserveWhitespace ) {
                            coreReaderImpl.ChangeCurrentNodeType( XmlNodeType.SignificantWhitespace );
                        }
                    }
                    goto default;
                case XmlNodeType.DocumentType:
                    ValidateDtd();
                    break;
                case XmlNodeType.EntityReference:
                    parsingFunction = ParsingFunction.ResolveEntityInternally;
                    goto default;
                default:
                    coreReaderImpl.InternalSchemaType = null;
                    coreReaderImpl.InternalTypedValue = null;
                    validator.Validate();
                    break;
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:25,代码来源:XmlValidatingReaderImpl.cs

示例4: MoveToElement

 // If on attribute, moves to the element that contains the attribute node
 public override bool MoveToElement() {
     if ( !coreReader.MoveToElement() ) {
         return false;
     }
     parsingFunction = ParsingFunction.Read;
     return true;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:8,代码来源:XmlValidatingReaderImpl.cs

示例5: Close

 // Closes the input stream ot TextReader, changes the ReadState to Closed and sets all properties to zero/string.Empty
 public override void Close() {
     coreReader.Close();
     parsingFunction = ParsingFunction.ReaderClosed;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:5,代码来源:XmlValidatingReaderImpl.cs

示例6: MoveToAttribute

 // Moves to an attribute with the specified Name
 public override bool MoveToAttribute( string name ) {
     if ( !coreReader.MoveToAttribute( name ) ) {
         return false;
     }
     parsingFunction = ParsingFunction.Read;
     return true;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:8,代码来源:XmlValidatingReaderImpl.cs

示例7: FinishReadContentAsBinary

        private void FinishReadContentAsBinary()
        {
            Debug.Assert(_parsingFunction == ParsingFunction.InReadContentAsBinary || _parsingFunction == ParsingFunction.InReadElementContentAsBinary);

            _readValueOffset = 0;
            if (_incReadState == IncrementalReadState.ReadContentAsBinary_OnPartialValue)
            {
                Debug.Assert((_index > 0) ? _nextParsingFunction == ParsingFunction.ElementContent : _nextParsingFunction == ParsingFunction.DocumentContent);
                SkipPartialTextValue();
            }
            else
            {
                _parsingFunction = _nextParsingFunction;
                _nextParsingFunction = _nextNextParsingFunction;
            }
            if (_incReadState != IncrementalReadState.ReadContentAsBinary_End)
            {
                while (MoveToNextContentNode(true)) ;
            }
        }
开发者ID:chcosta,项目名称:corefx,代码行数:20,代码来源:XmlTextReaderImpl.cs

示例8: SetupEndEntityNodeInContent

        private void SetupEndEntityNodeInContent()
        {
            Debug.Assert(_lastEntity != null);

            _reportedEncoding = _ps.encoding;
            _reportedBaseUri = _ps.baseUriStr;

            _curNode = _nodes[_index];
            Debug.Assert(_curNode.depth == _index);
            _curNode.SetNamedNode(XmlNodeType.EndEntity, _lastEntity.Name);
            _curNode.lineInfo.Set(_ps.lineNo, _ps.LinePos - 1);

            if (_index == 0 && _parsingFunction == ParsingFunction.ElementContent)
            {
                _parsingFunction = ParsingFunction.DocumentContent;
            }
        }
开发者ID:chcosta,项目名称:corefx,代码行数:17,代码来源:XmlTextReaderImpl.cs

示例9: SkipPartialTextValue

        private void SkipPartialTextValue()
        {
            Debug.Assert(_parsingFunction == ParsingFunction.PartialTextValue || _parsingFunction == ParsingFunction.InReadValueChunk ||
                          _parsingFunction == ParsingFunction.InReadContentAsBinary || _parsingFunction == ParsingFunction.InReadElementContentAsBinary);
            int startPos;
            int endPos;
            int orChars = 0;

            _parsingFunction = _nextParsingFunction;
            while (!ParseText(out startPos, out endPos, ref orChars)) ;
        }
开发者ID:chcosta,项目名称:corefx,代码行数:11,代码来源:XmlTextReaderImpl.cs

示例10: FinishReadValueChunk

        private void FinishReadValueChunk()
        {
            Debug.Assert(_parsingFunction == ParsingFunction.InReadValueChunk);

            _readValueOffset = 0;
            if (_incReadState == IncrementalReadState.ReadValueChunk_OnPartialValue)
            {
                Debug.Assert((_index > 0) ? _nextParsingFunction == ParsingFunction.ElementContent : _nextParsingFunction == ParsingFunction.DocumentContent);
                SkipPartialTextValue();
            }
            else
            {
                _parsingFunction = _nextParsingFunction;
                _nextParsingFunction = _nextNextParsingFunction;
            }
        }
开发者ID:chcosta,项目名称:corefx,代码行数:16,代码来源:XmlTextReaderImpl.cs

示例11: ParseText


//.........这里部分代码省略.........
                    case '<':
                        goto ReturnPartialValue;
                    // entity reference
                    case '&':
                        // try to parse char entity inline
                        int charRefEndPos, charCount;
                        EntityType entityType;
                        if ((charRefEndPos = ParseCharRefInline(pos, out charCount, out entityType)) > 0)
                        {
                            if (rcount > 0)
                            {
                                ShiftBuffer(rpos + rcount, rpos, pos - rpos - rcount);
                            }
                            rpos = pos - rcount;
                            rcount += (charRefEndPos - pos - charCount);
                            pos = charRefEndPos;

                            if (!_xmlCharType.IsWhiteSpace(chars[charRefEndPos - charCount]) ||
                                 (_v1Compat && entityType == EntityType.CharacterDec))
                            {
                                orChars |= 0xFF;
                            }
                        }
                        else
                        {
                            if (pos > _ps.charPos)
                            {
                                goto ReturnPartialValue;
                            }
                            switch (HandleEntityReference(false, EntityExpandType.All, out pos))
                            {
                                case EntityType.Unexpanded:
                                    // make sure we will report EntityReference after the text node
                                    _nextParsingFunction = _parsingFunction;
                                    _parsingFunction = ParsingFunction.EntityReference;
                                    // end the value (returns nothing)
                                    goto NoValue;
                                case EntityType.CharacterDec:
                                    if (!_v1Compat)
                                    {
                                        goto case EntityType.CharacterHex;
                                    }
                                    orChars |= 0xFF;
                                    break;
                                case EntityType.CharacterHex:
                                case EntityType.CharacterNamed:
                                    if (!_xmlCharType.IsWhiteSpace(_ps.chars[pos - 1]))
                                    {
                                        orChars |= 0xFF;
                                    }
                                    break;
                                default:
                                    pos = _ps.charPos;
                                    break;
                            }
                            chars = _ps.chars;
                        }
                        continue;
                    case ']':
                        if (_ps.charsUsed - pos < 3 && !_ps.isEof)
                        {
                            goto ReadData;
                        }
                        if (chars[pos + 1] == ']' && chars[pos + 2] == '>')
                        {
                            Throw(pos, SR.Xml_CDATAEndInText);
开发者ID:chcosta,项目名称:corefx,代码行数:67,代码来源:XmlTextReaderImpl.cs

示例12: XmlTextReaderImpl

        public XmlTextReaderImpl(string url, XmlNameTable nt) : this(nt)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }
            if (url.Length == 0)
            {
                throw new ArgumentException(SR.Xml_EmptyUrl, nameof(url));
            }
            _namespaceManager = new XmlNamespaceManager(nt);

            _url = url;

            // It is important to have valid resolver here to resolve the Xml url file path. 
            // it is safe as this resolver will not be used to resolve DTD url's
            _ps.baseUri = GetTempResolver().ResolveUri(null, url);
            _ps.baseUriStr = _ps.baseUri.ToString();
            _reportedBaseUri = _ps.baseUriStr;

            _parsingFunction = ParsingFunction.OpenUrl;
        }
开发者ID:chcosta,项目名称:corefx,代码行数:22,代码来源:XmlTextReaderImpl.cs

示例13: ReadElementContentAsBinary

        private int ReadElementContentAsBinary(byte[] buffer, int index, int count)
        {
            if (count == 0)
            {
                return 0;
            }
            int decoded = ReadContentAsBinary(buffer, index, count);
            if (decoded > 0)
            {
                return decoded;
            }

            // if 0 bytes returned check if we are on a closing EndElement, throw exception if not
            if (_curNode.type != XmlNodeType.EndElement)
            {
                throw new XmlException(SR.Xml_InvalidNodeType, _curNode.type.ToString(), this as IXmlLineInfo);
            }

            // reset state
            _parsingFunction = _nextParsingFunction;
            _nextParsingFunction = _nextNextParsingFunction;
            Debug.Assert(_parsingFunction != ParsingFunction.InReadElementContentAsBinary);

            // move off the EndElement
            _outerReader.Read();
            return 0;
        }
开发者ID:chcosta,项目名称:corefx,代码行数:27,代码来源:XmlTextReaderImpl.cs

示例14: ParseDoctypeDecl

        // Parses DOCTYPE declaration
        private bool ParseDoctypeDecl()
        {
            if (_dtdProcessing == DtdProcessing.Prohibit)
            {
                ThrowWithoutLineInfo(_v1Compat ? SR.Xml_DtdIsProhibited : SR.Xml_DtdIsProhibitedEx);
            }

            // parse 'DOCTYPE'
            while (_ps.charsUsed - _ps.charPos < 8)
            {
                if (ReadData() == 0)
                {
                    Throw(SR.Xml_UnexpectedEOF, "DOCTYPE");
                }
            }
            if (!XmlConvert.StrEqual(_ps.chars, _ps.charPos, 7, "DOCTYPE"))
            {
                ThrowUnexpectedToken((!_rootElementParsed && _dtdInfo == null) ? "DOCTYPE" : "<!--");
            }
            if (!_xmlCharType.IsWhiteSpace(_ps.chars[_ps.charPos + 7]))
            {
                ThrowExpectingWhitespace(_ps.charPos + 7);
            }

            if (_dtdInfo != null)
            {
                Throw(_ps.charPos - 2, SR.Xml_MultipleDTDsProvided);  // position just before <!DOCTYPE
            }
            if (_rootElementParsed)
            {
                Throw(_ps.charPos - 2, SR.Xml_DtdAfterRootElement);
            }

            _ps.charPos += 8;

            EatWhitespaces(null);

            if (_dtdProcessing == DtdProcessing.Parse)
            {
                _curNode.SetLineInfo(_ps.LineNo, _ps.LinePos);

                ParseDtd();

                _nextParsingFunction = _parsingFunction;
                _parsingFunction = ParsingFunction.ResetAttributesRootLevel;
                return true;
            }
            // Skip DTD
            else
            {
                Debug.Assert(_dtdProcessing == DtdProcessing.Ignore);

                SkipDtd();
                return false;
            }
        }
开发者ID:chcosta,项目名称:corefx,代码行数:57,代码来源:XmlTextReaderImpl.cs

示例15: XmlValidatingReaderImpl

        internal XmlValidatingReaderImpl( Stream xmlFragment, XmlNodeType fragType, XmlParserContext context )
            : this( new XmlTextReader( xmlFragment, fragType, context ) )
        {
            if ( coreReader.BaseURI.Length > 0 ) {
                validator.BaseUri = GetResolver().ResolveUri( null, coreReader.BaseURI );
            }

            if ( context != null ) {
                parsingFunction = ParsingFunction.ParseDtdFromContext;
                parserContext = context;
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:XmlValidatingReaderImpl.cs


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