DerivedPropertyDescriptor.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 Type ComponentType
  46. {
  47. get {
  48. return componentType;
  49. }
  50. }
  51. public override bool IsReadOnly
  52. {
  53. get {
  54. return readOnly;
  55. }
  56. }
  57. public override Type PropertyType
  58. {
  59. get {
  60. return propertyType;
  61. }
  62. }
  63. }
  64. }