DerivedPropertyDescriptor.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // System.ComponentModel.DerivedPropertyDescriptor
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) 2002 Ximian, Inc (http://www.ximian.com)
  8. //
  9. using System;
  10. using System.Reflection;
  11. namespace System.ComponentModel
  12. {
  13. class DerivedPropertyDescriptor : PropertyDescriptor
  14. {
  15. bool readOnly;
  16. Type componentType;
  17. Type propertyType;
  18. PropertyInfo prop;
  19. protected DerivedPropertyDescriptor (string name, Attribute [] attrs)
  20. : base (name, attrs)
  21. {
  22. }
  23. public DerivedPropertyDescriptor (string name, Attribute [] attrs, int dummy)
  24. : this (name, attrs)
  25. {
  26. }
  27. public void SetReadOnly (bool value)
  28. {
  29. readOnly = value;
  30. }
  31. public void SetComponentType (Type type)
  32. {
  33. componentType = type;
  34. }
  35. public void SetPropertyType (Type type)
  36. {
  37. propertyType = type;
  38. }
  39. public override object GetValue (object component)
  40. {
  41. if (prop == null)
  42. prop = componentType.GetProperty (Name);
  43. return prop.GetValue (component, null);
  44. }
  45. public override void SetValue(object component, object value) {
  46. if (prop == null)
  47. prop = componentType.GetProperty (Name);
  48. prop.SetValue (component, value, null);
  49. }
  50. [MonoTODO]
  51. public override void ResetValue(object component) {
  52. throw new NotImplementedException ();
  53. }
  54. [MonoTODO]
  55. public override bool CanResetValue(object component) {
  56. throw new NotImplementedException ();
  57. }
  58. [MonoTODO]
  59. public override bool ShouldSerializeValue(object component) {
  60. throw new NotImplementedException ();
  61. }
  62. public override Type ComponentType
  63. {
  64. get {
  65. return componentType;
  66. }
  67. }
  68. public override bool IsReadOnly
  69. {
  70. get {
  71. return readOnly;
  72. }
  73. }
  74. public override Type PropertyType
  75. {
  76. get {
  77. return propertyType;
  78. }
  79. }
  80. }
  81. }