System.Xml.Schema.XmlSchemaCollection.Add C# (CSharp) Method

Add() public method

public Add ( XmlSchema schema, XmlResolver resolver ) : XmlSchema
schema XmlSchema
resolver System.Xml.XmlResolver
return XmlSchema
	    public XmlSchema Add(XmlSchema schema, XmlResolver resolver)
        {
            if (schema == null)
                throw new ArgumentNullException(nameof(schema));

            SchemaInfo schemaInfo = new SchemaInfo();
            schemaInfo.SchemaType = SchemaType.XSD;
            return Add(schema.TargetNamespace, schemaInfo, schema, true, resolver);
        }

Same methods

XmlSchemaCollection::Add ( String ns, XmlReader reader ) : XmlSchema
XmlSchemaCollection::Add ( String ns, XmlReader reader, XmlResolver resolver ) : XmlSchema
XmlSchemaCollection::Add ( XmlSchema schema ) : XmlSchema
XmlSchemaCollection::Add ( string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile ) : XmlSchema
XmlSchemaCollection::Add ( string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile, XmlResolver resolver ) : XmlSchema
XmlSchemaCollection::Add ( string ns, string uri ) : XmlSchema
XmlSchemaCollection::Add ( XmlSchemaCollection schema ) : void
XmlSchemaCollection::Add ( string ns, XmlSchemaCollectionNode node ) : void

Usage Example

		public void TestAdd ()
		{
			XmlSchemaCollection col = new XmlSchemaCollection ();
			XmlSchema schema = new XmlSchema ();
			XmlSchemaElement elem = new XmlSchemaElement ();
			elem.Name = "foo";
			schema.Items.Add (elem);
			schema.TargetNamespace = "urn:foo";
			col.Add (schema);
			col.Add (schema);	// No problem !?

			XmlSchema schema2 = new XmlSchema ();
			schema2.Items.Add (elem);
			schema2.TargetNamespace = "urn:foo";
			col.Add (schema2);	// No problem !!

			schema.Compile (null);
			col.Add (schema);
			col.Add (schema);	// Still no problem !!!

			schema2.Compile (null);
			col.Add (schema2);

			schema = GetSchema ("Test/XmlFiles/xsd/3.xsd");
			schema.Compile (null);
			col.Add (schema);

			schema2 = GetSchema ("Test/XmlFiles/xsd/3.xsd");
			schema2.Compile (null);
			col.Add (schema2);
		}
All Usage Examples Of System.Xml.Schema.XmlSchemaCollection::Add