2 // System.Web.SiteMapNodeCollection
5 // Ben Maurer (bmaurer@users.sourceforge.net)
11 using System.Collections;
12 using System.Collections.Specialized;
16 namespace System.Web {
17 public class SiteMapNodeCollection : CollectionBase, IHierarchicalEnumerable {
18 public SiteMapNodeCollection () {}
19 public SiteMapNodeCollection (SiteMapNode value) { Add (value); }
20 public SiteMapNodeCollection (SiteMapNode[] values) { AddRangeInternal (values); }
21 public SiteMapNodeCollection (SiteMapNodeCollection values) { AddRangeInternal (values); }
23 public virtual int Add (SiteMapNode value)
26 throw new ArgumentNullException ("value");
27 return this.List.Add (value);
30 public virtual void AddRange (System.Web.SiteMapNode[] value)
32 this.OnAddRange (value);
33 this.AddRangeInternal (value);
36 public virtual void AddRange (SiteMapNodeCollection value)
38 this.OnAddRange (value);
39 this.AddRangeInternal (value);
42 private void AddRangeInternal (IList value)
45 throw new ArgumentNullException ("value");
46 this.InnerList.AddRange (value);
48 public bool Contains (SiteMapNode value)
50 return this.List.Contains (value);
53 public void CopyTo (System.Web.SiteMapNode[] array, int index)
55 this.List.CopyTo (array, index);
58 // public SiteMapDataSourceView GetDataSourceView ()
60 // return new SiteMapDataSourceView (this);
63 public int IndexOf (SiteMapNode value)
65 return this.List.IndexOf (value);
68 public virtual void Insert (int index, SiteMapNode value)
70 this.List.Insert (index, value);
73 protected virtual void OnAddRange (IList value)
77 protected override void OnValidate (object value)
79 base.OnValidate (value);
80 if (value as SiteMapNode == null)
81 throw new ArgumentException ("Invalid type");
84 public static SiteMapNodeCollection ReadOnly (SiteMapNodeCollection collection)
86 return new ReadOnlySiteMapNodeCollection (collection);
89 public virtual void Remove (SiteMapNode value)
91 this.List.Remove (value);
94 IHierarchyData System.Web.UI.IHierarchicalEnumerable.GetHierarchyData (object enumeratedItem)
96 return enumeratedItem as IHierarchyData;
99 public virtual SiteMapNode this [int index] {
100 get { return (SiteMapNode) this.List [index]; }
101 set { this.List [index] = value; }
104 private class ReadOnlySiteMapNodeCollection : SiteMapNodeCollection {
106 internal ReadOnlySiteMapNodeCollection (SiteMapNodeCollection collection) : base (collection) {}
108 protected override void OnAddRange (IList value) { throw new NotSupportedException ("Readonly collection"); }
109 protected override void OnClear () { throw new NotSupportedException ("Readonly collection"); }
110 protected override void OnInsert (int index, object value) { throw new NotSupportedException ("Readonly collection"); }
111 protected override void OnRemove (int index, object value) { throw new NotSupportedException ("Readonly collection"); }
112 protected override void OnSet (int index, object oldValue, object newValue) { throw new NotSupportedException ("Readonly collection"); }