System.Xml.Schema.SchemaInfo.Add C# (CSharp) Méthode

Add() public méthode

public Add ( SchemaInfo sinfo, ValidationEventHandler eventhandler ) : void
sinfo SchemaInfo
eventhandler ValidationEventHandler
Résultat void
        public void Add(SchemaInfo sinfo, ValidationEventHandler eventhandler) {
            if (schemaType == SchemaType.None) {
                schemaType = sinfo.SchemaType;
            }
            else if (schemaType != sinfo.SchemaType) {
                if (eventhandler != null) {
                    eventhandler(this, new ValidationEventArgs(new XmlSchemaException(Res.Sch_MixSchemaTypes, string.Empty)));
                }
                return;
            }

            foreach(string tns in sinfo.TargetNamespaces.Keys) {
                if (!targetNamespaces.ContainsKey(tns)) {
                    targetNamespaces.Add(tns, true);
                }
            }

            foreach(DictionaryEntry entry in sinfo.elementDecls) {
                if (!elementDecls.ContainsKey(entry.Key)) {
                    elementDecls.Add(entry.Key, entry.Value);
                }
            }
            foreach(DictionaryEntry entry in sinfo.elementDeclsByType) {
                if (!elementDeclsByType.ContainsKey(entry.Key)) {
                    elementDeclsByType.Add(entry.Key, entry.Value);
                }   
            }
            foreach (SchemaAttDef attdef in sinfo.AttributeDecls.Values) {
                if (!attributeDecls.ContainsKey(attdef.Name)) {
                    attributeDecls.Add(attdef.Name, attdef);
                }
            }
            foreach (SchemaNotation notation in sinfo.Notations.Values) {
                if (!Notations.ContainsKey(notation.Name.Name)) {
                    Notations.Add(notation.Name.Name, notation);
                }
            }

        }

Usage Example

        private void LoadSchema(string uri, string url)
        {
            if (this.XmlResolver == null)
            {
                return;
            }
            if (SchemaInfo.TargetNamespaces.ContainsKey(uri) && nsManager.LookupPrefix(uri) != null)
            {
                return;
            }

            SchemaInfo schemaInfo = null;

            if (SchemaCollection != null)
            {
                schemaInfo = SchemaCollection.GetSchemaInfo(uri);
            }
            if (schemaInfo != null)
            {
                if (schemaInfo.SchemaType != SchemaType.XSD)
                {
                    throw new XmlException(Res.Xml_MultipleValidaitonTypes, string.Empty, this.PositionInfo.LineNumber, this.PositionInfo.LinePosition);
                }
                SchemaInfo.Add(schemaInfo, EventHandler);
                return;
            }
            if (url != null)
            {
                LoadSchemaFromLocation(uri, url);
            }
        }
All Usage Examples Of System.Xml.Schema.SchemaInfo::Add