MemberDescriptor.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // System.ComponentModel.MemberDescriptor.cs
  3. //
  4. // Author:
  5. // Miguel de Icaza ([email protected])
  6. //
  7. // (C) Ximian, Inc. http://www.ximian.com
  8. //
  9. namespace System.ComponentModel {
  10. public abstract class MemberDescriptor {
  11. string name;
  12. Attribute [] attrs;
  13. protected MemberDescriptor (string name, Attribute [] attrs)
  14. {
  15. this.name = name;
  16. this.attrs = attrs;
  17. }
  18. protected MemberDescriptor (MemberDescriptor reference, Attribute [] attrs)
  19. {
  20. name = reference.name;
  21. this.attrs = attrs;
  22. }
  23. protected MemberDescriptor (string name)
  24. {
  25. this.name = name;
  26. }
  27. protected MemberDescriptor (MemberDescriptor reference)
  28. {
  29. name = reference.name;
  30. attrs = reference.attrs;
  31. }
  32. protected virtual Attribute [] AttributeArray {
  33. get {
  34. return attrs;
  35. }
  36. set {
  37. attrs = value;
  38. }
  39. }
  40. // FIXME: Implement Attributes property
  41. [MonoTODO ("Implement Attributes property too")]
  42. public virtual string Category {
  43. get {
  44. foreach (Attribute attr in attrs){
  45. if (attr is CategoryAttribute){
  46. return ((CategoryAttribute) attr).Category;
  47. }
  48. }
  49. return "Misc";
  50. }
  51. }
  52. public virtual string Description {
  53. get {
  54. foreach (Attribute attr in attrs){
  55. if (attr is DescriptionAttribute)
  56. return ((DescriptionAttribute) attr).Description;
  57. }
  58. return "";
  59. }
  60. }
  61. public virtual bool DesignTimeOnly {
  62. get {
  63. foreach (Attribute attr in attrs){
  64. if (attr is DesignOnlyAttribute)
  65. return ((DesignOnlyAttribute) attr).IsDesignOnly;
  66. }
  67. return false;
  68. }
  69. }
  70. //
  71. // FIXME: Is there any difference between DisplayName and Name?
  72. //
  73. [MonoTODO ("Does this diff from Name ?")]
  74. public virtual string DisplayName {
  75. get {
  76. return name;
  77. }
  78. }
  79. public virtual string Name {
  80. get {
  81. return name;
  82. }
  83. }
  84. public virtual bool IsBrowsable {
  85. get {
  86. foreach (Attribute attr in attrs){
  87. if (attr is BrowsableAttribute)
  88. return ((BrowsableAttribute) attr).Browsable;
  89. }
  90. return false;
  91. }
  92. }
  93. protected virtual int NameHashCode {
  94. get {
  95. return name.GetHashCode ();
  96. }
  97. }
  98. }
  99. }