2004-02-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web / SiteMapNodeCollection.cs
1 //
2 // System.Web.SiteMapNodeCollection
3 //
4 // Authors:
5 //      Ben Maurer (bmaurer@users.sourceforge.net)
6 //
7 //  (C) 2003 Ben Maurer
8 //
9
10 #if NET_1_2
11 using System.Collections;
12 using System.Collections.Specialized;
13 using System.Text;
14 using System.Web.UI;
15
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); }
22                 
23                 public virtual int Add (SiteMapNode value)
24                 {
25                         if (value == null)
26                                 throw new ArgumentNullException ("value");
27                         return this.List.Add (value);
28                 }
29                 
30                 public virtual void AddRange (System.Web.SiteMapNode[] value)
31                 {
32                         this.OnAddRange (value);
33                         this.AddRangeInternal (value);
34                 }
35                 
36                 public virtual void AddRange (SiteMapNodeCollection value)
37                 {
38                         this.OnAddRange (value);
39                         this.AddRangeInternal (value);
40                 }
41                 
42                 private void AddRangeInternal (IList value)
43                 {
44                         if (value == null)
45                                 throw new ArgumentNullException ("value");
46                         this.InnerList.AddRange (value);
47                 }
48                 public bool Contains (SiteMapNode value)
49                 {
50                         return this.List.Contains (value);
51                 }
52                 
53                 public void CopyTo (System.Web.SiteMapNode[] array, int index)
54                 {
55                         this.List.CopyTo (array, index);
56                 }
57                 
58 //              public SiteMapDataSourceView GetDataSourceView ()
59 //              {
60 //                      return new SiteMapDataSourceView (this);
61 //              }
62                 
63                 public int IndexOf (SiteMapNode value)
64                 {
65                         return this.List.IndexOf (value);
66                 }
67                 
68                 public virtual void Insert (int index, SiteMapNode value)
69                 {
70                         this.List.Insert (index, value);
71                 }
72                 
73                 protected virtual void OnAddRange (IList value)
74                 {
75                 }
76                 
77                 protected override void OnValidate (object value)
78                 {
79                         base.OnValidate (value);
80                         if (value as SiteMapNode == null)
81                                 throw new ArgumentException ("Invalid type");
82                 }
83                 
84                 public static SiteMapNodeCollection ReadOnly (SiteMapNodeCollection collection)
85                 {
86                         return new ReadOnlySiteMapNodeCollection (collection);
87                 }
88                 
89                 public virtual void Remove (SiteMapNode value)
90                 {
91                         this.List.Remove (value);
92                 }
93                 
94                 IHierarchyData System.Web.UI.IHierarchicalEnumerable.GetHierarchyData (object enumeratedItem)
95                 {
96                         return enumeratedItem as IHierarchyData;
97                 }
98                 
99                 public virtual SiteMapNode this [int index] {
100                         get { return (SiteMapNode) this.List [index]; }
101                         set { this.List [index] = value; }
102                 }
103
104                 private class ReadOnlySiteMapNodeCollection : SiteMapNodeCollection {
105                         
106                         internal ReadOnlySiteMapNodeCollection (SiteMapNodeCollection collection) : base (collection) {}
107
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"); }
113                 }
114                  
115         }
116 }
117 #endif
118