コード例 #1
0
 Task <Tuple <int, bool> > IDtdParserAdapter.PushEntityAsync(IDtdEntityInfo entity)
 {
     return(_reader.DtdParserProxy_PushEntityAsync(entity));
 }
コード例 #2
0
 bool IDtdParserAdapter.PushEntity(IDtdEntityInfo entity, out int entityId)
 {
     return(_reader.DtdParserProxy_PushEntity(entity, out entityId));
 }
コード例 #3
0
ファイル: XmlTextReaderImpl.cs プロジェクト: chcosta/corefx
        private void PushInternalEntity(IDtdEntityInfo entity)
        {
            Debug.Assert(!entity.IsExternal);

            Encoding enc = _ps.encoding;

            PushParsingState();

            InitStringInput((entity.DeclaredUriString != null) ? entity.DeclaredUriString : string.Empty, enc, entity.Text ?? string.Empty);

            RegisterEntity(entity);

            _ps.lineNo = entity.LineNumber;
            _ps.lineStartPos = -entity.LinePosition - 1;

            _ps.eolNormalized = true;

            RegisterConsumedCharacters(entity.Text.Length, true);
        }
コード例 #4
0
ファイル: XmlTextReaderImpl.cs プロジェクト: chcosta/corefx
        private void RegisterEntity(IDtdEntityInfo entity)
        {
            // check entity recursion
            if (_currentEntities != null)
            {
                if (_currentEntities.ContainsKey(entity))
                {
                    Throw(entity.IsParameterEntity ? SR.Xml_RecursiveParEntity : SR.Xml_RecursiveGenEntity, entity.Name,
                        _parsingStatesStack[_parsingStatesStackTop].LineNo, _parsingStatesStack[_parsingStatesStackTop].LinePos);
                }
            }

            // save the entity to parsing state & assign it an ID
            _ps.entity = entity;
            _ps.entityId = _nextEntityId++;

            // register entity for recursion checkes
            if (entity != null)
            {
                if (_currentEntities == null)
                {
                    _currentEntities = new Dictionary<IDtdEntityInfo, IDtdEntityInfo>();
                }
                _currentEntities.Add(entity, entity);
            }
        }
コード例 #5
0
ファイル: XmlTextReaderImpl.cs プロジェクト: chcosta/corefx
        // return true if EndEntity node should be reported. The entity is stored in lastEntity.
        private bool HandleEntityEnd(bool checkEntityNesting)
        {
            if (_parsingStatesStackTop == -1)
            {
                Debug.Assert(false);
                Throw(SR.Xml_InternalError);
            }

            if (_ps.entityResolvedManually)
            {
                _index--;

                if (checkEntityNesting)
                {
                    if (_ps.entityId != _nodes[_index].entityId)
                    {
                        Throw(SR.Xml_IncompleteEntity);
                    }
                }

                _lastEntity = _ps.entity;  // save last entity for the EndEntity node

                PopEntity();
                return true;
            }
            else
            {
                if (checkEntityNesting)
                {
                    if (_ps.entityId != _nodes[_index].entityId)
                    {
                        Throw(SR.Xml_IncompleteEntity);
                    }
                }

                PopEntity();

                _reportedEncoding = _ps.encoding;
                _reportedBaseUri = _ps.baseUriStr;
                return false;
            }
        }
コード例 #6
0
ファイル: XmlTextReaderImpl.cs プロジェクト: chcosta/corefx
        // returns true if real entity has been pushed, false if fake entity (=empty content entity)
        // SxS: The method neither takes any name of resource directly nor it exposes any resource to the caller. 
        // Entity info was created based on source document. It's OK to suppress the SxS warning
        private bool PushExternalEntity(IDtdEntityInfo entity)
        {
            Debug.Assert(entity.IsExternal);

            if (!IsResolverNull)
            {
                Uri entityBaseUri = null;
                if (!string.IsNullOrEmpty(entity.BaseUriString))
                {
                    entityBaseUri = _xmlResolver.ResolveUri(null, entity.BaseUriString);
                }
                PushExternalEntityOrSubset(entity.PublicId, entity.SystemId, entityBaseUri, entity.Name);

                RegisterEntity(entity);

                Debug.Assert(_ps.appendMode);
                int initialPos = _ps.charPos;
                if (_v1Compat)
                {
                    EatWhitespaces(null);
                }
                if (!ParseXmlDeclaration(true))
                {
                    _ps.charPos = initialPos;
                }
                return true;
            }
            else
            {
                Encoding enc = _ps.encoding;

                PushParsingState();
                InitStringInput(entity.SystemId, enc, string.Empty);

                RegisterEntity(entity);

                RegisterConsumedCharacters(0, true);

                return false;
            }
        }
コード例 #7
0
ファイル: XmlTextReaderImpl.cs プロジェクト: chcosta/corefx
 internal bool DtdParserProxy_PushEntity(IDtdEntityInfo entity, out int entityId)
 {
     bool retValue;
     if (entity.IsExternal)
     {
         if (IsResolverNull)
         {
             entityId = -1;
             return false;
         }
         retValue = PushExternalEntity(entity);
     }
     else
     {
         PushInternalEntity(entity);
         retValue = true;
     }
     entityId = _ps.entityId;
     return retValue;
 }
コード例 #8
0
ファイル: XmlTextReaderImpl.cs プロジェクト: chcosta/corefx
 internal bool DtdParserProxy_PopEntity(out IDtdEntityInfo oldEntity, out int newEntityId)
 {
     if (_parsingStatesStackTop == -1)
     {
         oldEntity = null;
         newEntityId = -1;
         return false;
     }
     oldEntity = _ps.entity;
     PopEntity();
     newEntityId = _ps.entityId;
     return true;
 }
コード例 #9
0
ファイル: XmlTextReaderImpl.cs プロジェクト: JianwenSun/cc
        private bool HandleEntityEnd( bool checkEntityNesting ) {
#endif
            if ( parsingStatesStackTop == -1 ) {
                Debug.Assert( false );
                Throw( Res.Xml_InternalError );
            }

#if !SILVERLIGHT // Needed only for XmlTextReader (reporting of entities)
            if ( ps.entityResolvedManually ) {
                index--;

                if ( checkEntityNesting ) {
                    if ( ps.entityId != nodes[index].entityId ) {
                        Throw( Res.Xml_IncompleteEntity );
                    }
                }

                lastEntity = ps.entity;  // save last entity for the EndEntity node

                PopEntity();
                return true;
            }
            else {
#endif
            if ( checkEntityNesting ) {
                    if ( ps.entityId != nodes[index].entityId ) {
                        Throw( Res.Xml_IncompleteEntity );
                    }
                }

                PopEntity();

                reportedEncoding = ps.encoding;
                reportedBaseUri = ps.baseUriStr;
#if !SILVERLIGHT // Needed only for XmlTextReader (reporting of entities)
                return false;
            }
#endif
            }
コード例 #10
0
 Task<Tuple<int, bool>> IDtdParserAdapter.PushEntityAsync(IDtdEntityInfo entity)
 {
     return _reader.DtdParserProxy_PushEntityAsync(entity);
 }
コード例 #11
0
 bool IDtdParserAdapter.PopEntity(out IDtdEntityInfo oldEntity, out int newEntityId)
 {
     return(_reader.DtdParserProxy_PopEntity(out oldEntity, out newEntityId));
 }
コード例 #12
0
        internal async Task<Tuple<int, bool>> DtdParserProxy_PushEntityAsync(IDtdEntityInfo entity)
        {
            CheckAsyncCall();
            int entityId;

            bool retValue;
            if (entity.IsExternal)
            {
                if (IsResolverNull)
                {
                    entityId = -1;

                    return new Tuple<int, bool>(entityId, false);
                }
                retValue = await PushExternalEntityAsync(entity).ConfigureAwait(false);
            }
            else
            {
                PushInternalEntity(entity);
                retValue = true;
            }
            entityId = _ps.entityId;

            return new Tuple<int, bool>(entityId, retValue);
        }
コード例 #13
0
        private async Task< bool > PushExternalEntityAsync( IDtdEntityInfo entity ) {
            Debug.Assert( entity.IsExternal );

            if (!IsResolverNull) {

                Uri entityBaseUri = null;
                // Resolve base URI
                if (!string.IsNullOrEmpty(entity.BaseUriString)) {
                    entityBaseUri = xmlResolver.ResolveUri(null, entity.BaseUriString);
                }
                await PushExternalEntityOrSubsetAsync( entity.PublicId,  entity.SystemId, entityBaseUri,  entity.Name ).ConfigureAwait(false);

                RegisterEntity(entity);

                Debug.Assert( ps.appendMode );
                int initialPos = ps.charPos;
                if ( v1Compat ) {
                    await EatWhitespacesAsync( null ).ConfigureAwait(false);
                }
                if ( !await ParseXmlDeclarationAsync( true ).ConfigureAwait(false) ) {
                    ps.charPos = initialPos;
                }
                return true;
            }
            else {
                Encoding enc = ps.encoding;

                PushParsingState();
                InitStringInput( entity.SystemId, enc, string.Empty );

                RegisterEntity(entity);

                RegisterConsumedCharacters(0, true);

                return false;
            }
        }