2003-04-11 Sebastien Pouliot <spouliot@videotron.ca>
[mono.git] / mcs / class / System / System.ComponentModel / DerivedPropertyDescriptor.cs
1 //
2 // System.ComponentModel.DerivedPropertyDescriptor
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (C) 2002 Ximian, Inc (http://www.ximian.com)
8 //
9 using System;
10 using System.Reflection;
11
12 namespace System.ComponentModel
13 {
14         class DerivedPropertyDescriptor : PropertyDescriptor
15         {
16                 bool readOnly;
17                 Type componentType;
18                 Type propertyType;
19                 PropertyInfo prop;
20
21                 protected DerivedPropertyDescriptor (string name, Attribute [] attrs)
22                         : base (name, attrs)
23                 {
24                 }
25
26                 public DerivedPropertyDescriptor (string name, Attribute [] attrs, int dummy)
27                         : this (name, attrs)
28                 {
29                 }
30
31                 public void SetReadOnly (bool value)
32                 {
33                         readOnly = value;
34                 }
35                 
36                 public void SetComponentType (Type type)
37                 {
38                         componentType = type;
39                 }
40
41                 public void SetPropertyType (Type type)
42                 {
43                         propertyType = type;
44                 }
45
46                 public override object GetValue (object component)
47                 {
48                         if (prop == null)
49                                 prop = componentType.GetProperty (Name);
50
51                         return prop.GetValue (component, null);
52                 }
53
54                 public override void SetValue(object component, object value) {
55                         
56                         if (prop == null)
57                                 prop = componentType.GetProperty (Name);
58
59                         prop.SetValue (component, value, null);
60                 }
61
62                 [MonoTODO]
63                 public override void ResetValue(object component) {
64
65                         throw new NotImplementedException ();
66                 }
67
68                 [MonoTODO]
69                 public override bool CanResetValue(object component) {
70
71                         throw new NotImplementedException ();
72                 }
73
74                 [MonoTODO]
75                 public override bool ShouldSerializeValue(object component) {
76
77                         throw new NotImplementedException ();
78                 }
79
80                 public override Type ComponentType
81                 {
82                         get {
83                                 return componentType;
84                         }
85
86                 }
87
88                 public override bool IsReadOnly
89                 {
90                         get {
91                                 return readOnly;
92                                 
93                         }
94
95                 }
96
97                 public override Type PropertyType
98                 {
99                         get {
100                                 return propertyType;
101                         }
102
103                 }
104         }
105 }
106