13 [IndexerName(
"ItemOf")]
32 [IndexerName(
"ItemOf")]
37 int hashCode = XmlName.GetHashCode(name);
38 for (
int i = 0; i < nodes.Count; i++)
41 if (hashCode == xmlAttribute.LocalNameHash && name == xmlAttribute.
Name)
54 [IndexerName(
"ItemOf")]
55 public XmlAttribute this[
string localName,
string namespaceURI]
59 int hashCode = XmlName.GetHashCode(localName);
60 for (
int i = 0; i < nodes.Count; i++)
63 if (hashCode == xmlAttribute.LocalNameHash && localName == xmlAttribute.
LocalName && namespaceURI == xmlAttribute.
NamespaceURI)
102 internal XmlAttributeCollection(XmlNode parent)
107 internal int FindNodeOffset(XmlAttribute node)
109 for (
int i = 0; i < nodes.Count; i++)
111 XmlAttribute xmlAttribute = (XmlAttribute)nodes[i];
112 if (xmlAttribute.LocalNameHash == node.LocalNameHash && xmlAttribute.Name == node.Name && xmlAttribute.NamespaceURI == node.NamespaceURI)
120 internal int FindNodeOffsetNS(XmlAttribute node)
122 for (
int i = 0; i < nodes.Count; i++)
124 XmlAttribute xmlAttribute = (XmlAttribute)nodes[i];
125 if (xmlAttribute.LocalNameHash == node.LocalNameHash && xmlAttribute.LocalName == node.LocalName && xmlAttribute.NamespaceURI == node.NamespaceURI)
151 XmlNode result = base.RemoveNodeAt(num);
152 InsertNodeAt(num, node);
169 RemoveDuplicateAttribute(node);
170 InsertNodeAt(0, node);
182 if (ownerDocument ==
null || !ownerDocument.IsLoading)
184 if (ownerDocument !=
null && ownerDocument != parent.
OwnerDocument)
196 base.AddNodeForLoad(node, ownerDocument);
197 InsertParentIntoElementIdAttrMap(node);
209 if (newNode == refNode)
230 int num2 = RemoveDuplicateAttribute(newNode);
231 if (num2 >= 0 && num2 < num)
235 InsertNodeAt(num, newNode);
246 if (newNode == refNode)
267 int num2 = RemoveDuplicateAttribute(newNode);
268 if (num2 >= 0 && num2 < num)
272 InsertNodeAt(num + 1, newNode);
281 int count = nodes.Count;
282 for (
int i = 0; i < count; i++)
284 if (nodes[i] == node)
298 if (i < 0 || i >= Count)
325 array.SetValue(nodes[num], index);
349 XmlNode result = base.AddNode(node);
354 internal override XmlNode InsertNodeAt(
int i, XmlNode node)
356 XmlNode result = base.InsertNodeAt(i, node);
357 InsertParentIntoElementIdAttrMap((XmlAttribute)node);
361 internal override XmlNode RemoveNodeAt(
int i)
363 XmlNode xmlNode = base.RemoveNodeAt(i);
364 RemoveParentFromElementIdAttrMap((XmlAttribute)xmlNode);
365 XmlAttribute defaultAttribute = parent.OwnerDocument.GetDefaultAttribute((XmlElement)parent, xmlNode.Prefix, xmlNode.LocalName, xmlNode.NamespaceURI);
366 if (defaultAttribute !=
null)
368 InsertNodeAt(i, defaultAttribute);
373 internal void Detach(XmlAttribute attr)
375 attr.OwnerElement.Attributes.Remove(attr);
378 internal void InsertParentIntoElementIdAttrMap(XmlAttribute attr)
380 XmlElement xmlElement = parent as XmlElement;
381 if (xmlElement !=
null && parent.OwnerDocument !=
null)
383 XmlName iDInfoByElement = parent.OwnerDocument.GetIDInfoByElement(xmlElement.XmlName);
384 if (iDInfoByElement !=
null && iDInfoByElement.Prefix == attr.XmlName.Prefix && iDInfoByElement.LocalName == attr.XmlName.LocalName)
386 parent.OwnerDocument.AddElementWithId(attr.Value, xmlElement);
391 internal void RemoveParentFromElementIdAttrMap(XmlAttribute attr)
393 XmlElement xmlElement = parent as XmlElement;
394 if (xmlElement !=
null && parent.OwnerDocument !=
null)
396 XmlName iDInfoByElement = parent.OwnerDocument.GetIDInfoByElement(xmlElement.XmlName);
397 if (iDInfoByElement !=
null && iDInfoByElement.Prefix == attr.XmlName.Prefix && iDInfoByElement.LocalName == attr.XmlName.LocalName)
399 parent.OwnerDocument.RemoveElementWithId(attr.Value, xmlElement);
404 internal int RemoveDuplicateAttribute(XmlAttribute attr)
406 int num = FindNodeOffset(attr.LocalName, attr.NamespaceURI);
409 XmlAttribute attr2 = (XmlAttribute)nodes[num];
410 base.RemoveNodeAt(num);
411 RemoveParentFromElementIdAttrMap(attr2);
416 internal bool PrepareParentInElementIdAttrMap(
string attrPrefix,
string attrLocalName)
418 XmlElement xmlElement = parent as XmlElement;
419 XmlDocument ownerDocument = parent.OwnerDocument;
420 XmlName iDInfoByElement = ownerDocument.GetIDInfoByElement(xmlElement.XmlName);
421 if (iDInfoByElement !=
null && iDInfoByElement.Prefix == attrPrefix && iDInfoByElement.LocalName == attrLocalName)
428 internal void ResetParentInElementIdAttrMap(
string oldVal,
string newVal)
430 XmlElement elem = parent as XmlElement;
431 XmlDocument ownerDocument = parent.OwnerDocument;
432 ownerDocument.RemoveElementWithId(oldVal, elem);
433 ownerDocument.AddElementWithId(newVal, elem);
436 internal XmlAttribute InternalAppendAttribute(XmlAttribute node)
438 XmlNode xmlNode = base.AddNode(node);
439 InsertParentIntoElementIdAttrMap(node);
440 return (XmlAttribute)xmlNode;
Represents an XML document. You can use this class to load, validate, edit, add, and position XML in ...
object SyncRoot
Gets an object that can be used to synchronize access to the T:System.Collections....
XmlAttribute Remove(XmlAttribute node)
Removes the specified attribute from the collection.
abstract string LocalName
Gets the local name of the node, when overridden in a derived class.
void CopyTo(XmlAttribute[] array, int index)
Copies all the T:System.Xml.XmlAttribute objects from this collection into the given array.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
Represents an attribute. Valid and default values for the attribute are defined in a document type de...
virtual string NamespaceURI
Gets the namespace URI of this node.
Represents a collection of nodes that can be accessed by name or index.
override string NamespaceURI
Gets the namespace URI of this node.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
The exception that is thrown when an attempt is made to access an element of an array or collection w...
override XmlNode SetNamedItem(XmlNode node)
Adds a T:System.Xml.XmlNode using its P:System.Xml.XmlNode.Name property
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
bool IsSynchronized
Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (threa...
XmlAttribute Append(XmlAttribute node)
Inserts the specified attribute as the last node in the collection.
override XmlDocument OwnerDocument
Gets the T:System.Xml.XmlDocument to which the current node belongs.
The exception that is thrown when one of the arguments provided to a method is not valid.
override string LocalName
Gets the local name of the node.
XmlAttribute Prepend(XmlAttribute node)
Inserts the specified attribute as the first node in the collection.
virtual XmlElement OwnerElement
Gets the T:System.Xml.XmlElement to which the attribute belongs.
void RemoveAll()
Removes all attributes from the collection.
XmlAttribute InsertAfter(XmlAttribute newNode, XmlAttribute refNode)
Inserts the specified attribute immediately after the specified reference attribute.
Represents a collection of attributes that can be accessed by name or index.
int Count
Gets the number of elements contained in the T:System.Collections.ICollection.
XmlAttribute RemoveAt(int i)
Removes the attribute corresponding to the specified index from the collection.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
override XmlDocument OwnerDocument
Gets the T:System.Xml.XmlDocument to which this node belongs.
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
XmlAttribute InsertBefore(XmlAttribute newNode, XmlAttribute refNode)
Inserts the specified attribute immediately before the specified reference attribute.
override string Name
Gets the qualified name of the node.
Represents a single node in the XML document.