// // System.Xml.XmlAttributeCollection // // Author: // Jason Diamond (jason@injektilo.org) // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp) // // (C) 2002 Jason Diamond http://injektilo.org/ // (C) 2002 Atsushi Enomoto // using System; using System.Collections; using Mono.Xml; namespace System.Xml { public class XmlAttributeCollection : XmlNamedNodeMap, ICollection { XmlElement ownerElement; XmlDocument ownerDocument; internal XmlAttributeCollection (XmlNode parent) : base (parent) { ownerElement = parent as XmlElement; ownerDocument = parent.OwnerDocument; if(ownerElement == null) throw new XmlException ("invalid construction for XmlAttributeCollection."); } bool ICollection.IsSynchronized { get { return false; } } bool IsReadOnly { get { return ownerElement.IsReadOnly; } } [System.Runtime.CompilerServices.IndexerName ("ItemOf")] public virtual XmlAttribute this [string name] { get { return (XmlAttribute) GetNamedItem (name); } } [System.Runtime.CompilerServices.IndexerName ("ItemOf")] public virtual XmlAttribute this [int i] { get { return (XmlAttribute) Nodes [i]; } } [System.Runtime.CompilerServices.IndexerName ("ItemOf")] public virtual XmlAttribute this [string localName, string namespaceURI] { get { return (XmlAttribute) GetNamedItem (localName, namespaceURI); } } object ICollection.SyncRoot { get { return this; } } public virtual XmlAttribute Append (XmlAttribute node) { XmlNode xmlNode = this.SetNamedItem (node); return node; } public void CopyTo (XmlAttribute[] array, int index) { // assuming that Nodes is a correct collection. for(int i=0; i Nodes.Count) throw new XmlException ("refNode not found in this collection."); } else pos = 0; SetNamedItem (newNode, pos); ownerDocument.onNodeInserted (newNode, null); return newNode; } public virtual XmlAttribute InsertBefore (XmlAttribute newNode, XmlAttribute refNode) { if(newNode.OwnerDocument != ownerDocument) throw new ArgumentException ("different document created this newNode."); ownerDocument.onNodeInserting (newNode, null); int pos = Nodes.Count; if(refNode != null) { for(int i=0; i