ParseChildrenAttribute.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // System.Web.UI.ParseChildrenAttribute.cs
  3. //
  4. // Authors:
  5. // Duncan Mak ([email protected])
  6. // Gonzalo Paniagua ([email protected])
  7. //
  8. // (C) 2002 Ximian, Inc. (http://www.ximian.com
  9. //
  10. using System;
  11. namespace System.Web.UI {
  12. [AttributeUsage (AttributeTargets.Class)]
  13. public sealed class ParseChildrenAttribute : Attribute
  14. {
  15. bool childrenAsProperties;
  16. string defaultProperty;
  17. public static readonly ParseChildrenAttribute Default = new ParseChildrenAttribute ();
  18. // LAMESPEC
  19. public ParseChildrenAttribute ()
  20. {
  21. childrenAsProperties = false;
  22. defaultProperty = "";
  23. }
  24. public ParseChildrenAttribute (bool childrenAsProperties)
  25. {
  26. this.childrenAsProperties = childrenAsProperties;
  27. this.defaultProperty = "";
  28. }
  29. public ParseChildrenAttribute (bool childrenAsProperties,
  30. string defaultProperty)
  31. {
  32. this.childrenAsProperties = childrenAsProperties;
  33. if (childrenAsProperties)
  34. this.defaultProperty = defaultProperty;
  35. }
  36. public bool ChildrenAsProperties {
  37. get { return childrenAsProperties; }
  38. set { childrenAsProperties = value; }
  39. }
  40. public string DefaultProperty {
  41. get { return defaultProperty; }
  42. set { defaultProperty = value; }
  43. }
  44. public override bool Equals (object obj)
  45. {
  46. if (!(obj is ParseChildrenAttribute))
  47. return false;
  48. ParseChildrenAttribute o = (ParseChildrenAttribute) obj;
  49. if (childrenAsProperties == o.childrenAsProperties){
  50. if (childrenAsProperties == false)
  51. return true;
  52. return (defaultProperty == o.DefaultProperty);
  53. }
  54. return false;
  55. }
  56. public override int GetHashCode ()
  57. {
  58. return base.GetHashCode ();
  59. }
  60. public override bool IsDefaultAttribute ()
  61. {
  62. return Equals (Default);
  63. }
  64. }
  65. }