C# 클래스 System.ComponentModel.ReflectPropertyDescriptor

ReflectPropertyDescriptor defines a property. Properties are the main way that a user can set up the state of a component. The ReflectPropertyDescriptor class takes a component class that the property lives on, a property name, the type of the property, and various attributes for the property. For a property named XXX of type YYY, the associated component class is required to implement two methods of the following form:

public YYY GetXXX(); public void SetXXX(YYY value); The component class can optionally implement two additional methods of the following form: public boolean ShouldSerializeXXX(); public void ResetXXX(); These methods deal with a property's default value. The ShouldSerializeXXX() method returns true if the current value of the XXX property is different than it's default value, so that it should be persisted out. The ResetXXX() method resets the XXX property to its default value. If the ReflectPropertyDescriptor includes the default value of the property (using the DefaultValueAttribute), the ShouldSerializeXXX() and ResetXXX() methods are ignored. If the ReflectPropertyDescriptor includes a reference to an editor then that value editor will be used to edit the property. Otherwise, a system-provided editor will be used. Various attributes can be passed to the ReflectPropertyDescriptor, as are described in Attribute. ReflectPropertyDescriptors can be obtained by a user programmatically through the ComponentManager.
상속: PropertyDescriptor
파일 보기 프로젝트 열기: dotnet/corefx 1 사용 예제들

Private Properties

프로퍼티 타입 설명
ExtenderCanResetValue bool
ExtenderGetReceiverType Type
ExtenderGetType Type
ExtenderGetValue object
ExtenderResetValue void
ExtenderSetValue void
ExtenderShouldSerializeValue bool
OnINotifyPropertyChanged void

공개 메소드들

메소드 설명
AddValueChanged ( object component, EventHandler handler ) : void

Allows interested objects to be notified when this property changes.

CanResetValue ( object component ) : bool

Indicates whether reset will change the value of the component. If there is a DefaultValueAttribute, then this will return true if getValue returns something different than the default value. If there is a reset method and a ShouldSerialize method, this will return what ShouldSerialize returns. If there is just a reset method, this always returns true. If none of these cases apply, this returns false.

GetValue ( object component ) : object

Retrieves the current value of the property on component, invoking the getXXX method. An exception in the getXXX method will pass through.

ReflectPropertyDescriptor ( Type componentClass, PropertyDescriptor oldReflectPropertyDescriptor, Attribute attributes ) : System.Collections

This constructor takes an existing ReflectPropertyDescriptor and modifies it by merging in the passed-in attributes.

ReflectPropertyDescriptor ( Type componentClass, string name, Type type, Attribute attributes ) : System.Collections

The main constructor for ReflectPropertyDescriptors.

ReflectPropertyDescriptor ( Type componentClass, string name, Type type, PropertyInfo propInfo, MethodInfo getMethod, MethodInfo setMethod, Attribute attrs ) : System.Collections

A constructor for ReflectPropertyDescriptors that have no attributes.

ReflectPropertyDescriptor ( Type componentClass, string name, Type type, Type receiverType, MethodInfo getMethod, MethodInfo setMethod, Attribute attrs ) : System.Collections

A constructor for ReflectPropertyDescriptors that creates an extender property.

RemoveValueChanged ( object component, EventHandler handler ) : void

Allows interested objects to be notified when this property changes.

ResetValue ( object component ) : void

Will reset the default value for this property on the component. If there was a default value passed in as a DefaultValueAttribute, that value will be set as the value of the property on the component. If there was no default value passed in, a ResetXXX method will be looked for. If one is found, it will be invoked. If one is not found, this is a nop.

SetValue ( object component, object value ) : void

This will set value to be the new value of this property on the component by invoking the setXXX method on the component. If the value specified is invalid, the component should throw an exception which will be passed up. The component designer should design the property so that getXXX following a setXXX should return the value passed in if no exception was thrown in the setXXX call.

ShouldSerializeValue ( object component ) : bool

Indicates whether the value of this property needs to be persisted. In other words, it indicates whether the state of the property is distinct from when the component is first instantiated. If there is a default value specified in this ReflectPropertyDescriptor, it will be compared against the property's current value to determine this. If there is't, the ShouldSerializeXXX method is looked for and invoked if found. If both these routes fail, true will be returned. If this returns false, a tool should not persist this property's value.

보호된 메소드들

메소드 설명
FillAttributes ( IList attributes ) : void
OnValueChanged ( object component, EventArgs e ) : void

This should be called by your property descriptor implementation when the property value has changed.

비공개 메소드들

메소드 설명
ExtenderCanResetValue ( IExtenderProvider provider, object component ) : bool
ExtenderGetReceiverType ( ) : Type
ExtenderGetType ( IExtenderProvider provider ) : Type
ExtenderGetValue ( IExtenderProvider provider, object component ) : object
ExtenderResetValue ( IExtenderProvider provider, object component, PropertyDescriptor notifyDesc ) : void
ExtenderSetValue ( IExtenderProvider provider, object component, object value, PropertyDescriptor notifyDesc ) : void
ExtenderShouldSerializeValue ( IExtenderProvider provider, object component ) : bool
OnINotifyPropertyChanged ( object component, PropertyChangedEventArgs e ) : void

Handles INotifyPropertyChanged.PropertyChange events from components. If event pertains to this property, issue a ValueChanged event.

메소드 상세

AddValueChanged() 공개 메소드

Allows interested objects to be notified when this property changes.
public AddValueChanged ( object component, EventHandler handler ) : void
component object
handler EventHandler
리턴 void

CanResetValue() 공개 메소드

Indicates whether reset will change the value of the component. If there is a DefaultValueAttribute, then this will return true if getValue returns something different than the default value. If there is a reset method and a ShouldSerialize method, this will return what ShouldSerialize returns. If there is just a reset method, this always returns true. If none of these cases apply, this returns false.
public CanResetValue ( object component ) : bool
component object
리턴 bool

FillAttributes() 보호된 메소드

protected FillAttributes ( IList attributes ) : void
attributes IList
리턴 void

GetValue() 공개 메소드

Retrieves the current value of the property on component, invoking the getXXX method. An exception in the getXXX method will pass through.
public GetValue ( object component ) : object
component object
리턴 object

OnValueChanged() 보호된 메소드

This should be called by your property descriptor implementation when the property value has changed.
protected OnValueChanged ( object component, EventArgs e ) : void
component object
e EventArgs
리턴 void

ReflectPropertyDescriptor() 공개 메소드

This constructor takes an existing ReflectPropertyDescriptor and modifies it by merging in the passed-in attributes.
public ReflectPropertyDescriptor ( Type componentClass, PropertyDescriptor oldReflectPropertyDescriptor, Attribute attributes ) : System.Collections
componentClass Type
oldReflectPropertyDescriptor PropertyDescriptor
attributes Attribute
리턴 System.Collections

ReflectPropertyDescriptor() 공개 메소드

The main constructor for ReflectPropertyDescriptors.
public ReflectPropertyDescriptor ( Type componentClass, string name, Type type, Attribute attributes ) : System.Collections
componentClass Type
name string
type Type
attributes Attribute
리턴 System.Collections

ReflectPropertyDescriptor() 공개 메소드

A constructor for ReflectPropertyDescriptors that have no attributes.
public ReflectPropertyDescriptor ( Type componentClass, string name, Type type, PropertyInfo propInfo, MethodInfo getMethod, MethodInfo setMethod, Attribute attrs ) : System.Collections
componentClass Type
name string
type Type
propInfo System.Reflection.PropertyInfo
getMethod System.Reflection.MethodInfo
setMethod System.Reflection.MethodInfo
attrs Attribute
리턴 System.Collections

ReflectPropertyDescriptor() 공개 메소드

A constructor for ReflectPropertyDescriptors that creates an extender property.
public ReflectPropertyDescriptor ( Type componentClass, string name, Type type, Type receiverType, MethodInfo getMethod, MethodInfo setMethod, Attribute attrs ) : System.Collections
componentClass Type
name string
type Type
receiverType Type
getMethod System.Reflection.MethodInfo
setMethod System.Reflection.MethodInfo
attrs Attribute
리턴 System.Collections

RemoveValueChanged() 공개 메소드

Allows interested objects to be notified when this property changes.
public RemoveValueChanged ( object component, EventHandler handler ) : void
component object
handler EventHandler
리턴 void

ResetValue() 공개 메소드

Will reset the default value for this property on the component. If there was a default value passed in as a DefaultValueAttribute, that value will be set as the value of the property on the component. If there was no default value passed in, a ResetXXX method will be looked for. If one is found, it will be invoked. If one is not found, this is a nop.
public ResetValue ( object component ) : void
component object
리턴 void

SetValue() 공개 메소드

This will set value to be the new value of this property on the component by invoking the setXXX method on the component. If the value specified is invalid, the component should throw an exception which will be passed up. The component designer should design the property so that getXXX following a setXXX should return the value passed in if no exception was thrown in the setXXX call.
public SetValue ( object component, object value ) : void
component object
value object
리턴 void

ShouldSerializeValue() 공개 메소드

Indicates whether the value of this property needs to be persisted. In other words, it indicates whether the state of the property is distinct from when the component is first instantiated. If there is a default value specified in this ReflectPropertyDescriptor, it will be compared against the property's current value to determine this. If there is't, the ShouldSerializeXXX method is looked for and invoked if found. If both these routes fail, true will be returned. If this returns false, a tool should not persist this property's value.
public ShouldSerializeValue ( object component ) : bool
component object
리턴 bool