System.Xml.XmlTextReaderImpl.AddDefaultAttributeNonDtd C# (CSharp) Méthode

AddDefaultAttributeNonDtd() private méthode

private AddDefaultAttributeNonDtd ( SchemaAttDef attrDef ) : bool
attrDef System.Xml.Schema.SchemaAttDef
Résultat bool
        internal bool AddDefaultAttributeNonDtd(SchemaAttDef attrDef)
        {
            // atomize names - Xsd Validator does not need to have the same nametable
            string localName = _nameTable.Add(attrDef.Name.Name);
            string prefix = _nameTable.Add(attrDef.Prefix);
            string ns = _nameTable.Add(attrDef.Name.Namespace);

            // atomize namespace - Xsd Validator does not need to have the same nametable
            if (prefix.Length == 0 && ns.Length > 0)
            {
                prefix = _namespaceManager.LookupPrefix(ns);

                Debug.Assert(prefix != null);
                if (prefix == null)
                {
                    prefix = string.Empty;
                }
            }

            // find out if the attribute is already there
            for (int i = _index + 1; i < _index + 1 + _attrCount; i++)
            {
                if ((object)_nodes[i].localName == (object)localName &&
                    (((object)_nodes[i].prefix == (object)prefix) || ((object)_nodes[i].ns == (object)ns && ns != null)))
                {
                    return false;
                }
            }

            // attribute does not exist -> we need to add it
            NodeData attr = AddDefaultAttributeInternal(localName, ns, prefix, attrDef.DefaultValueExpanded,
                                                         attrDef.LineNumber, attrDef.LinePosition,
                                                         attrDef.ValueLineNumber, attrDef.ValueLinePosition, attrDef.Reserved != SchemaAttDef.Reserve.None);
            Debug.Assert(attr != null);

            attr.schemaType = (attrDef.SchemaType == null) ? (object)attrDef.Datatype : (object)attrDef.SchemaType;
            attr.typedValue = attrDef.DefaultValueTyped;
            return true;
        }

Usage Example

 internal bool AddDefaultAttribute(SchemaAttDef attdef)
 {
     return(coreReaderImpl.AddDefaultAttributeNonDtd(attdef));
 }
XmlTextReaderImpl