System.Xml.Schema.XmlSchemaObjectCollection Class

Assembly: System.Xml.dll
Namespace: System.Xml.Schema
Summary
An object collection class to handle XmlSchemaObjects when collections are returned from method calls.
C# Syntax:
public class XmlSchemaObjectCollection : CollectionBase
Example
See XmlSchemaObject for an example using this class.
See also:
System.Xml.Schema Namespace

System.Xml.Schema.XmlSchemaObjectCollection Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the XmlSchemaObjectCollection class.
ctor #2 Overloaded:
.ctor(XmlSchemaObject parent)

Initializes a new instance of the XmlSchemaObjectCollection class that takes an XmlSchemaObject.
Public Properties
Count
(inherited from System.Collections.CollectionBase)
Read-only

See base class member description: System.Collections.CollectionBase.Count


Gets the number of elements contained in the CollectionBase instance.
Item Read-write

Looks up the qualified name using the supplied XmlQualifiedName and returns the XmlSchemaObject, the XML Schema definition language (XSD) element for this qualified name.
Public Methods
Add Adds an XmlSchemaObject to the XmlSchemaObjectCollection.
Clear
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.Clear


Removes all objects from the CollectionBase instance.
Contains Indicates if the specified qualified name is located in the XmlSchemaObjectCollection.
CopyTo Copies all the XmlSchemaObjects from the collection into the given array starting at the given index.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetEnumerator Returns an enumerator for iterating through the XmlSchemaObjects contained in the XmlSchemaObjectCollection.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
IndexOf Gets the index of the specified XmlSchemaObject within the collection of the specified item.
Insert Inserts an XmlSchemaObject to the XmlSchemaObjectCollection.
Remove Removes an XmlSchemaObject from the XmlSchemaObjectCollection.
RemoveAt
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.RemoveAt


Removes the element at the specified index of the CollectionBase instance.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Properties
InnerList
(inherited from System.Collections.CollectionBase)
Read-only

See base class member description: System.Collections.CollectionBase.InnerList


Gets an ArrayList containing the list of elements in the CollectionBase instance.
List
(inherited from System.Collections.CollectionBase)
Read-only

See base class member description: System.Collections.CollectionBase.List


Gets an IList containing the list of elements in the CollectionBase instance.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.
OnClear Overridden:
OnClear is invoked before the standard Clear behavior. For more information, see OnClear method for CollectionBase.
OnClearComplete
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnClearComplete


Performs additional custom processes after clearing the contents of the CollectionBase instance.
OnInsert Overridden:
OnInsert is invoked before the standard Insert behavior. For more information, see OnInsert method CollectionBase.
OnInsertComplete
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnInsertComplete


Performs additional custom processes after inserting a new element into the CollectionBase instance.
OnRemove Overridden:
OnRemove is invoked before the standard Remove behavior. For more information, see OnRemove method for CollectionBase.
OnRemoveComplete
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnRemoveComplete


Performs additional custom processes after removing an element from the CollectionBase instance.
OnSet Overridden:
OnSet is invoked before the standard Set behavior. For more information, see OnSet method for CollectionBase.
OnSetComplete
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnSetComplete


Performs additional custom processes after setting a value in the CollectionBase instance.
OnValidate
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnValidate


Performs additional custom processes when validating a value.

Hierarchy:


System.Xml.Schema.XmlSchemaObjectCollection Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the XmlSchemaObjectCollection class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public XmlSchemaObjectCollection();

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the XmlSchemaObjectCollection class that takes an XmlSchemaObject.
C# Syntax:
public XmlSchemaObjectCollection(
   XmlSchemaObject parent
);
Parameters:

parent

The XmlSchemaObject.

Return to top


Property: Count (read-only)
Inherited
See base class member description: System.Collections.CollectionBase.Count

Summary
Gets the number of elements contained in the CollectionBase instance.
C# Syntax:
public int Count {get;}
Implements:
ICollection.Count

Return to top


Property: InnerList (read-only)
Inherited
See base class member description: System.Collections.CollectionBase.InnerList

Summary
Gets an ArrayList containing the list of elements in the CollectionBase instance.
C# Syntax:
protected ArrayList InnerList {get;}
Remarks
The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.

Return to top


Property: Item (read-write)
Summary
Looks up the qualified name using the supplied XmlQualifiedName and returns the XmlSchemaObject, the XML Schema definition language (XSD) element for this qualified name.
C# Syntax:
public virtual XmlSchemaObject this[int index] {get; set;}
Parameters:

index

The index of the XmlSchemaObject.

Return to top


Property: List (read-only)
Inherited
See base class member description: System.Collections.CollectionBase.List

Summary
Gets an IList containing the list of elements in the CollectionBase instance.
C# Syntax:
protected IList List {get;}
Remarks
The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.

Return to top


Method: Add(
   XmlSchemaObject item
)
Summary
Adds an XmlSchemaObject to the XmlSchemaObjectCollection.
C# Syntax:
public int Add(
   XmlSchemaObject item
);
Parameters:

item

The XmlSchemaObject.

Return Value:
The index at which the item has been added.
Exceptions
Exception Type Condition
ArgumentOutOfRangeException index is less than zero. -or-

index is greater than Count.

Remarks
If Count already equals the capacity, the capacity of list is doubled by automatically reallocated the internal array and copying the existing elements to the new array before the new element is added.

If Count is less than the capacity, this method is an 0(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an 0(n) operation, where n is Count.

Return to top


Method: Clear()
Inherited
See base class member description: System.Collections.CollectionBase.Clear

Summary
Removes all objects from the CollectionBase instance.
C# Syntax:
public void Clear();
Implements:
IList.Clear
Remarks
CollectionBase.Count is set to zero.

Return to top


Method: Contains(
   XmlSchemaObject item
)
Summary
Indicates if the specified qualified name is located in the XmlSchemaObjectCollection.
C# Syntax:
public bool Contains(
   XmlSchemaObject item
);
Parameters:

item

The XmlSchemaObject.

Return Value:
true if the specified qualified name is in the collection. Otherwise returns false. If null is supplied, false is returned because there is no qualified name with a null name.

Return to top


Method: CopyTo(
   XmlSchemaObject[] array,
   int index
)
Summary
Copies all the XmlSchemaObjects from the collection into the given array starting at the given index.
C# Syntax:
public void CopyTo(
   XmlSchemaObject[] array,
   int index
);
Parameters:

array

The one-dimensional array that is the destination of the elements copied from the XmlSchemaObjectCollection. The array must have zero-based indexing. The one-dimensional array that is the destination of the elements copied from the XmlSchemaObjectCollection. The array must have zero-based indexing.

index

The zero-based index in the array at which copying begins. The zero-based index in the array at which copying begins.

Exceptions
Exception Type Condition
ArgumentNullException array is a null reference (not set or empty).
ArgumentOutOfRangeException index is less than zero.
ArgumentException array is multidimensional.

- or -

index is equal to or greater than the length of array.

- or -

The number of elements in the source XmlSchemaObject is greater than the available space from index to the end of the destination array.

InvalidCastException The type of the source XmlSchemaObject cannot be cast automatically to the type of the destination array.
Remarks
The specified array must be of a compatible type.

This method uses Array.Copy to copy the elements.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~XmlSchemaObjectCollection();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetEnumerator()
Summary
Returns an enumerator for iterating through the XmlSchemaObjects contained in the XmlSchemaObjectCollection.
C# Syntax:
public new XmlSchemaObjectEnumerator GetEnumerator();
Return Value:
The iterator returns XmlSchemaObjectEnumerator.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: IndexOf(
   XmlSchemaObject item
)
Summary
Gets the index of the specified XmlSchemaObject within the collection of the specified item.
C# Syntax:
public int IndexOf(
   XmlSchemaObject item
);
Parameters:

item

The XmlSchemaObject.

Return to top


Method: Insert(
   int index,
   XmlSchemaObject item
)
Summary
Inserts an XmlSchemaObject to the XmlSchemaObjectCollection.
C# Syntax:
public void Insert(
   int index,
   XmlSchemaObject item
);
Parameters:

index

The zero-based index at which item should be inserted.

item

The XmlSchemaObject to insert.

Exceptions
Exception Type Condition
ArgumentOutOfRangeException index is less than zero. -or-

index is greater than Count.

Remarks
If Count already equals the capacity, the capacity of the list is doubled by automatically reallocating the internal array before the new element is inserted.

If index is equal to Count, value is added to the end of XmlSchemaObjectCollection.

The elements that follow the insertion point move down to accomodate the new element.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Overridden Method: OnClear()
Summary
OnClear is invoked before the standard Clear behavior. For more information, see OnClear method for CollectionBase.
C# Syntax:
protected override void OnClear();

Return to top


Method: OnClearComplete()
Inherited
See base class member description: System.Collections.CollectionBase.OnClearComplete

Summary
Performs additional custom processes after clearing the contents of the CollectionBase instance.
C# Syntax:
protected virtual void OnClearComplete();
Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action after the collection is cleared.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed after deleting all the elements from the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnClear is invoked before the standard Clear behavior, whereas CollectionBase.OnClearComplete is invoked after the standard Clear behavior.

See also:
CollectionBase.OnClear | CollectionBase.OnRemoveComplete

Return to top


Overridden Method: OnInsert(
   int index,
   object item
)
Summary
OnInsert is invoked before the standard Insert behavior. For more information, see OnInsert method CollectionBase.
C# Syntax:
protected override void OnInsert(
   int index,
   object item
);
Parameters:

index

The index of XmlSchemaObject.

item

The item.

Return to top


Method: OnInsertComplete(
   int index,
   object value
)
Inherited
See base class member description: System.Collections.CollectionBase.OnInsertComplete

Summary
Performs additional custom processes after inserting a new element into the CollectionBase instance.
C# Syntax:
protected virtual void OnInsertComplete(
   int index,
   object value
);
Parameters:

index

The zero-based index at which to insert value.

value

The new value of the element at index.

Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action after the specified element is inserted.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed after inserting the element into the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnInsert is invoked before the standard Insert behavior, whereas CollectionBase.OnInsertComplete is invoked after the standard Insert behavior.

See also:
CollectionBase.OnInsert | CollectionBase.OnSetComplete

Return to top


Overridden Method: OnRemove(
   int index,
   object item
)
Summary
OnRemove is invoked before the standard Remove behavior. For more information, see OnRemove method for CollectionBase.
C# Syntax:
protected override void OnRemove(
   int index,
   object item
);
Parameters:

index

The index of XmlSchemaObject.

item

The item.

Return to top


Method: OnRemoveComplete(
   int index,
   object value
)
Inherited
See base class member description: System.Collections.CollectionBase.OnRemoveComplete

Summary
Performs additional custom processes after removing an element from the CollectionBase instance.
C# Syntax:
protected virtual void OnRemoveComplete(
   int index,
   object value
);
Parameters:

index

The zero-based index at which value can be found.

value

The value of the element to remove from index.

Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action after the specified element is removed.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed after removing the element from the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnRemove is invoked before the standard Remove behavior, whereas CollectionBase.OnRemoveComplete is invoked after the standard Remove behavior.

See also:
CollectionBase.OnRemove | CollectionBase.OnClearComplete

Return to top


Overridden Method: OnSet(
   int index,
   object oldValue,
   object newValue
)
Summary
OnSet is invoked before the standard Set behavior. For more information, see OnSet method for CollectionBase.
C# Syntax:
protected override void OnSet(
   int index,
   object oldValue,
   object newValue
);
Parameters:

index

The index of XmlSchemaObject.

oldValue

The old value.

newValue

The new value.

Return to top


Method: OnSetComplete(
   int index,
   object oldValue,
   object newValue
)
Inherited
See base class member description: System.Collections.CollectionBase.OnSetComplete

Summary
Performs additional custom processes after setting a value in the CollectionBase instance.
C# Syntax:
protected virtual void OnSetComplete(
   int index,
   object oldValue,
   object newValue
);
Parameters:

index

The zero-based index at which oldValue can be found.

oldValue

The value to replace with newValue.

newValue

The new value of the element at index.

Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action after the specified element is set.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed after setting the specified element in the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnSet is invoked before the standard Set behavior, whereas CollectionBase.OnSetComplete is invoked after the standard Set behavior.

See also:
CollectionBase.OnSet | CollectionBase.OnInsertComplete

Return to top


Method: OnValidate(
   object value
)
Inherited
See base class member description: System.Collections.CollectionBase.OnValidate

Summary
Performs additional custom processes when validating a value.
C# Syntax:
protected virtual void OnValidate(
   object value
);
Parameters:

value

The object to validate.

Remarks
The default implementation of this method determines whether value is null, and, if so, throws ArgumentNullException. It is intended to be overridden by a derived class to perform additional action when the specified element is validated.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed when executing the standard behavior of the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnValidate can be used to impose restrictions on the type of objects that are accepted into the collection. The default implementation prevents null from being added to or removed from the underlying ArrayList.

See also:
CollectionBase.OnSet | CollectionBase.OnInsert

Return to top


Method: Remove(
   XmlSchemaObject item
)
Summary
Removes an XmlSchemaObject from the XmlSchemaObjectCollection.
C# Syntax:
public void Remove(
   XmlSchemaObject item
);
Parameters:

item

The XmlSchemaObject to remove.

Remarks
This method performs a linear search; therefore, the average execution time is proportional to Count. That is, this method is an O(n) operation, where n is Count.

This method determines equality by calling Object.Equals.

The elements that follow the removed element move up to occupy the vacated spot.

Return to top


Method: RemoveAt(
   int index
)
Inherited
See base class member description: System.Collections.CollectionBase.RemoveAt

Summary
Removes the element at the specified index of the CollectionBase instance.
C# Syntax:
public void RemoveAt(
   int index
);
Parameters:

index

The zero-based index of the element to remove.

Exceptions
Exception Type Condition
ArgumentOutOfRangeException index is less than zero.

-or-

index is equal to or greater than CollectionBase.Count.

Implements:
IList.RemoveAt
Remarks
In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hashtable.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.