PropertyDescriptor.ShouldSerializeValue(Object) 方法

定義

在衍生類別中覆寫時,判斷指示這個屬性的值是否需要保存的值。

public:
 abstract bool ShouldSerializeValue(System::Object ^ component);
public abstract bool ShouldSerializeValue (object component);
abstract member ShouldSerializeValue : obj -> bool
Public MustOverride Function ShouldSerializeValue (component As Object) As Boolean

參數

component
Object

元件,具有要檢查保存性 (Persistence) 的屬性。

傳回

如果屬性應該要保存,則為 true,否則為 false

備註

一般而言,此方法是透過反映來實作。

給實施者的注意事項

在衍生類別中覆寫時,如果屬性的目前值與其預設值不同,這個方法會 true 傳回 。 它會先尋找 DefaultValueAttribute來尋找預設值。 如果方法找到這個屬性,它會比較屬性的值與屬性的目前值。 如果這個方法找不到 DefaultValueAttribute,它會尋找您需要實作的 “ShouldSerializeMyProperty” 方法。 如果找到,請 ShouldSerializeValue(Object) 叫用它。 如果這個方法找不到 DefaultValueAttribute 或 「ShouldSerializeMyProperty」 方法,它就無法建立優化,並傳 true回 。

注意:類別 ComponentDesigner 會實作繼承元件的特殊串行化邏輯。 如需詳細資訊,請參閱ComponentDesigner

適用於

另請參閱