PageRenderTime 28ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/IZWebFileManager/FileType.cs

http://izwebfilemanager.googlecode.com/
C# | 115 lines | 81 code | 19 blank | 15 comment | 9 complexity | 4fedf99b13c69b362e3427dd0ddd09f9 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.ObjectModel;
  21. using System.ComponentModel;
  22. using System.Web.UI.WebControls;
  23. using System.Drawing.Design;
  24. using System.Diagnostics.CodeAnalysis;
  25. namespace IZ.WebFileManager
  26. {
  27. [PersistChildren (false)]
  28. [ParseChildren (true)]
  29. public sealed class FileType : IStateManager
  30. {
  31. readonly StateBag bag = new StateBag ();
  32. readonly FileManagerCommandCollection fileManagerCommandCollection = new FileManagerCommandCollection ();
  33. [MergableProperty (true)]
  34. [PersistenceMode (PersistenceMode.InnerProperty)]
  35. public FileManagerCommandCollection Commands {
  36. get { return fileManagerCommandCollection; }
  37. }
  38. [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
  39. [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
  40. [DefaultValue ("")]
  41. [UrlProperty]
  42. [Bindable (true)]
  43. public string SmallImageUrl {
  44. get { return bag ["SmallIconUrl"] == null ? String.Empty : (string) bag ["SmallIconUrl"]; }
  45. set { bag ["SmallIconUrl"] = value; }
  46. }
  47. [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
  48. [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
  49. [DefaultValue ("")]
  50. [UrlProperty]
  51. [Bindable (true)]
  52. public string LargeImageUrl {
  53. get { return bag ["LargeIconUrl"] == null ? String.Empty : (string) bag ["LargeIconUrl"]; }
  54. set { bag ["LargeIconUrl"] = value; }
  55. }
  56. [DefaultValue ("")]
  57. public string Extensions {
  58. get { return bag ["Extensions"] == null ? String.Empty : (string) bag ["Extensions"]; }
  59. set { bag ["Extensions"] = value; }
  60. }
  61. [DefaultValue ("")]
  62. public string Name {
  63. get { return bag ["Name"] == null ? String.Empty : (string) bag ["Name"]; }
  64. set { bag ["Name"] = value; }
  65. }
  66. #region IStateManager Members
  67. bool IStateManager.IsTrackingViewState {
  68. get { return ((IStateManager) bag).IsTrackingViewState; }
  69. }
  70. void IStateManager.LoadViewState (object state) {
  71. if (state == null)
  72. return;
  73. object [] states = (object []) state;
  74. ((IStateManager) bag).LoadViewState (states [0]);
  75. ((IStateManager) Commands).LoadViewState (states [1]);
  76. }
  77. object IStateManager.SaveViewState () {
  78. object [] states = new object [2];
  79. states [0] = ((IStateManager) bag).SaveViewState ();
  80. states [1] = ((IStateManager) Commands).SaveViewState ();
  81. for (int i = 0; i < states.Length; i++) {
  82. if (states [i] != null)
  83. return states;
  84. }
  85. return null;
  86. }
  87. void IStateManager.TrackViewState () {
  88. ((IStateManager) bag).TrackViewState ();
  89. ((IStateManager) Commands).TrackViewState ();
  90. }
  91. #endregion
  92. internal void SetDirty () {
  93. bag.SetDirty (true);
  94. }
  95. }
  96. }