Udostępnij za pośrednictwem


XmlSchemaObjectCollection.Add(XmlSchemaObject) Metoda

Definicja

Dodaje element XmlSchemaObject do elementu XmlSchemaObjectCollection.

public:
 int Add(System::Xml::Schema::XmlSchemaObject ^ item);
public int Add(System.Xml.Schema.XmlSchemaObject item);
member this.Add : System.Xml.Schema.XmlSchemaObject -> int
Public Function Add (item As XmlSchemaObject) As Integer

Parametry

item
XmlSchemaObject

Element XmlSchemaObject do dodania do kolekcji.

Zwraca

Indeks, w którym został dodany element.

Wyjątki

Określony XmlSchemaObject parametr nie jest typu XmlSchemaExternal ani jego typów pochodnych XmlSchemaImport, XmlSchemaIncludei XmlSchemaRedefine.

Uwagi

Jeśli Count pojemność jest już równa pojemności, pojemność listy jest podwojona przez automatyczne przydzielenie tablicy wewnętrznej i skopiowanie istniejących elementów do nowej tablicy przed dodaniu nowego elementu.

Jeśli Count jest mniejsza niż pojemność, ta metoda jest operacją 0(1). Jeśli pojemność musi zostać zwiększona, aby pomieścić nowy element, ta metoda stanie się operacją 0(n), gdzie n to Count.

Metoda Add oczekuje tylko XmlSchemaExternal i jego typów pochodnych (XmlSchemaImport, XmlSchemaIncludei XmlSchemaRedefine) jako parametrów. Poniższy przykład ilustruje dodanie dołączonego schematu do Includes kolekcji istniejącego XmlSchema obiektu.

Dim schema As XmlSchema = New XmlSchema()

Dim textReader As XmlTextReader = New XmlTextReader("include.xsd")
Dim includeSchema As XmlSchema = XmlSchema.Read(textReader, null)

Dim include As XmlSchemaInclude = New XmlSchemaInclude()
include.Schema = includeSchema;
schema.Includes.Add(include);
XmlSchema schema = new XmlSchema();

XmlTextReader textReader = new XmlTextReader("include.xsd");
XmlSchema includeSchema = XmlSchema.Read(textReader, null);

XmlSchemaInclude include = new XmlSchemaInclude();
include.Schema = includeSchema;
schema.Includes.Add(include);

Dotyczy