Task <Tuple <int, bool> > IDtdParserAdapter.PushEntityAsync(IDtdEntityInfo entity) { return(_reader.DtdParserProxy_PushEntityAsync(entity)); }
bool IDtdParserAdapter.PushEntity(IDtdEntityInfo entity, out int entityId) { return(_reader.DtdParserProxy_PushEntity(entity, out entityId)); }
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); }
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); } }
// 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; } }
// 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; } }
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; }
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; }
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 }
Task<Tuple<int, bool>> IDtdParserAdapter.PushEntityAsync(IDtdEntityInfo entity) { return _reader.DtdParserProxy_PushEntityAsync(entity); }
bool IDtdParserAdapter.PopEntity(out IDtdEntityInfo oldEntity, out int newEntityId) { return(_reader.DtdParserProxy_PopEntity(out oldEntity, out newEntityId)); }
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); }
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; } }