PageRenderTime 173ms CodeModel.GetById 81ms app.highlight 4ms RepoModel.GetById 86ms app.codeStats 0ms

/IZWebFileManager/RootDirectoryCollection.cs

http://izwebfilemanager.googlecode.com/
C# | 88 lines | 58 code | 15 blank | 15 comment | 5 complexity | 074c52c82ad2bea137e029547f577ff8 MD5 | raw file
 1// Copyright (C) 2006 Igor Zelmanovich <izwebfilemanager@gmail.com>
 2//
 3// This program is free software; you can redistribute it and/or modify
 4// it under the terms of the GNU General Public License as published by
 5// the Free Software Foundation; either version 2 of the License, or
 6// (at your option) any later version.
 7//
 8// This program is distributed in the hope that it will be useful,
 9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17using System;
18using System.Collections.Generic;
19using System.Text;
20using System.Web.UI;
21using System.Collections;
22
23namespace IZ.WebFileManager
24{
25	public sealed class RootDirectoryCollection : StateManagedCollection
26	{
27		private static readonly Type [] _knownTypes = new Type [] { typeof (RootDirectory) };
28
29		public RootDirectory this [int i] {
30			get { return (RootDirectory) ((IList) this) [i]; }
31			set { ((IList) this) [i] = value; }
32		}
33
34		public RootDirectory this [string name] {
35			get {
36				for (int i = 0; i < Count; i++) {
37					RootDirectory dir = this [i];
38					if (String.Compare (dir.TextInternal, name, true) == 0)
39						return dir;
40				}
41				return null;
42			}
43		}
44
45		public int Add (RootDirectory rootDirectory) {
46			return ((IList) this).Add (rootDirectory);
47		}
48
49		public bool Contains (RootDirectory rootDirectory) {
50			return ((IList) this).Contains (rootDirectory);
51		}
52
53		public void CopyTo (RootDirectory [] rootDirectoryArray, int index) {
54			base.CopyTo (rootDirectoryArray, index);
55		}
56
57		public int IndexOf (RootDirectory rootDirectory) {
58			return ((IList) this).IndexOf (rootDirectory);
59		}
60
61		public void Insert (int index, RootDirectory rootDirectory) {
62			((IList) this).Insert (index, rootDirectory);
63		}
64
65		public void Remove (RootDirectory rootDirectory) {
66			((IList) this).Remove (rootDirectory);
67		}
68
69		public void RemoveAt (int index) {
70			((IList) this).RemoveAt (index);
71		}
72
73		protected override object CreateKnownType (int index) {
74			if (index != 0)
75				throw new ArgumentOutOfRangeException ("Unknown Type");
76
77			return new RootDirectory ();
78		}
79
80		protected override Type [] GetKnownTypes () {
81			return _knownTypes;
82		}
83
84		protected override void SetDirtyObject (object o) {
85			((RootDirectory) o).SetDirty ();
86		}
87	}
88}