PageRenderTime 37ms CodeModel.GetById 23ms RepoModel.GetById 0ms 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. using System;
  17. using System.Collections.Generic;
  18. using System.Text;
  19. using System.Web.UI;
  20. using System.Collections;
  21. namespace IZ.WebFileManager
  22. {
  23. public sealed class RootDirectoryCollection : StateManagedCollection
  24. {
  25. private static readonly Type [] _knownTypes = new Type [] { typeof (RootDirectory) };
  26. public RootDirectory this [int i] {
  27. get { return (RootDirectory) ((IList) this) [i]; }
  28. set { ((IList) this) [i] = value; }
  29. }
  30. public RootDirectory this [string name] {
  31. get {
  32. for (int i = 0; i < Count; i++) {
  33. RootDirectory dir = this [i];
  34. if (String.Compare (dir.TextInternal, name, true) == 0)
  35. return dir;
  36. }
  37. return null;
  38. }
  39. }
  40. public int Add (RootDirectory rootDirectory) {
  41. return ((IList) this).Add (rootDirectory);
  42. }
  43. public bool Contains (RootDirectory rootDirectory) {
  44. return ((IList) this).Contains (rootDirectory);
  45. }
  46. public void CopyTo (RootDirectory [] rootDirectoryArray, int index) {
  47. base.CopyTo (rootDirectoryArray, index);
  48. }
  49. public int IndexOf (RootDirectory rootDirectory) {
  50. return ((IList) this).IndexOf (rootDirectory);
  51. }
  52. public void Insert (int index, RootDirectory rootDirectory) {
  53. ((IList) this).Insert (index, rootDirectory);
  54. }
  55. public void Remove (RootDirectory rootDirectory) {
  56. ((IList) this).Remove (rootDirectory);
  57. }
  58. public void RemoveAt (int index) {
  59. ((IList) this).RemoveAt (index);
  60. }
  61. protected override object CreateKnownType (int index) {
  62. if (index != 0)
  63. throw new ArgumentOutOfRangeException ("Unknown Type");
  64. return new RootDirectory ();
  65. }
  66. protected override Type [] GetKnownTypes () {
  67. return _knownTypes;
  68. }
  69. protected override void SetDirtyObject (object o) {
  70. ((RootDirectory) o).SetDirty ();
  71. }
  72. }
  73. }