4 using System.Reflection;
6 namespace SiliconStudio.Core.Reflection
13 private readonly PropertyInfo propertyInfo;
14 private readonly MethodInfo getMethod;
15 private readonly MethodInfo setMethod;
24 : base(factory, propertyInfo)
26 if (propertyInfo == null)
throw new ArgumentNullException(
"propertyInfo");
28 this.propertyInfo = propertyInfo;
30 getMethod = propertyInfo.GetGetMethod(
false);
31 if (propertyInfo.CanWrite && propertyInfo.GetSetMethod(
false) != null)
33 setMethod = propertyInfo.GetSetMethod(
false);
35 this.TypeDescriptor = Factory.Find(propertyInfo.PropertyType);
42 public PropertyInfo PropertyInfo
50 public override Type Type
54 return propertyInfo.PropertyType;
58 public override object Get(
object thisObject)
60 return getMethod.Invoke(thisObject, null);
63 public override void Set(
object thisObject,
object value)
66 setMethod.Invoke(thisObject,
new[] {value});
69 public override bool HasSet
73 return setMethod != null;
83 return string.Format(
"Property [{0}] from Type [{1}]", Name, PropertyInfo.DeclaringType != null ? PropertyInfo.DeclaringType.FullName : string.Empty);
A IMemberDescriptor for a PropertyInfo
override object Get(object thisObject)
Gets the value of this member for the specified instance.
override void Set(object thisObject, object value)
Sets a value of this member for the specified instance.
Base class for IMemberDescriptor for a MemberInfo
A factory to create an instance of a ITypeDescriptor
override string ToString()
Returns a System.String that represents this instance.
PropertyDescriptor(ITypeDescriptorFactory factory, PropertyInfo propertyInfo)
Initializes a new instance of the PropertyDescriptor class.