System.Xml.DtdParser.VerifyEntityReference C# (CSharp) Méthode

VerifyEntityReference() private méthode

private VerifyEntityReference ( XmlQualifiedName entityName, bool paramEntity, bool mustBeDeclared, bool inAttribute ) : SchemaEntity
entityName XmlQualifiedName
paramEntity bool
mustBeDeclared bool
inAttribute bool
Résultat SchemaEntity
        private SchemaEntity VerifyEntityReference(XmlQualifiedName entityName, bool paramEntity, bool mustBeDeclared, bool inAttribute)
        {
            Debug.Assert(_chars[_curPos - 1] == ';');

            SchemaEntity entity;
            if (paramEntity)
            {
                _schemaInfo.ParameterEntities.TryGetValue(entityName, out entity);
            }
            else
            {
                _schemaInfo.GeneralEntities.TryGetValue(entityName, out entity);
            }

            if (entity == null)
            {
                if (paramEntity)
                {
#if !SILVERLIGHT
                    if (_validate)
                    {
                        SendValidationEvent(_curPos - entityName.Name.Length - 1, XmlSeverityType.Error, SR.Xml_UndeclaredParEntity, entityName.Name);
                    }
#endif
                }
                else if (mustBeDeclared)
                {
                    if (!ParsingInternalSubset)
                    {
#if !SILVERLIGHT
                        if (_validate)
                        {
                            SendValidationEvent(_curPos - entityName.Name.Length - 1, XmlSeverityType.Error, SR.Xml_UndeclaredEntity, entityName.Name);
                        }
#endif
                    }
                    else
                    {
                        Throw(_curPos - entityName.Name.Length - 1, SR.Xml_UndeclaredEntity, entityName.Name);
                    }
                }
                return null;
            }

            if (!entity.NData.IsEmpty)
            {
                Throw(_curPos - entityName.Name.Length - 1, SR.Xml_UnparsedEntityRef, entityName.Name);
            }

            if (inAttribute && entity.IsExternal)
            {
                Throw(_curPos - entityName.Name.Length - 1, SR.Xml_ExternalEntityInAttValue, entityName.Name);
            }

            return entity;
        }