Freezable.IsFrozen 屬性
定義
取得值,該值表示物件目前是否可修改。Gets a value that indicates whether the object is currently modifiable.
public:
property bool IsFrozen { bool get(); };
public bool IsFrozen { get; }
member this.IsFrozen : bool
Public ReadOnly Property IsFrozen As Boolean
屬性值
如果物件已凍結,而且無法修改則為 true
,如果可以修改物件則為 false
。true
if the object is frozen and cannot be modified; false
if the object can be modified.
備註
當物件的屬性擲回時,嘗試修改物件 IsFrozen true
InvalidOperationException 。Attempting to modify an object when its IsFrozen property is true
throws an InvalidOperationException.
從物件模型的觀點來看,這個屬性是唯讀的。This property is read-only from the object model perspective. 在 Freezable 討論其他方法的行為時,某些行為的檔可能會提及「設定 IsFrozen 為」 true
或類似的語言 Freezable ,但是當實例的方法操作存在於抽象類別中的私用變數時,就會在類別實例內部發生此行為。Some of the documentation about Freezable behaviors may mention "sets IsFrozen to true
" or similar language when discussing the behavior of other methods of Freezable, but this behavior is happening internally in the class instances, when methods of the instance manipulate the private variables that exist within the abstract class. 若要設定這個屬性的值,您應該呼叫 Freeze 。To set the value of this property, you should call Freeze. 這實際上是一次將 IsFrozen 屬性從初始預設 false
狀態變更為狀態的作業 true
。This effectively is a one-time operation to change the IsFrozen property from the initial default false
state to the true
state. 沒有可將值設定回的可用方法 false
。There is no available means to set the value back to false
. 相反地,您可以變更從原始 (進行的任何深層複製,請參閱 Clone) 方法。Instead, you could change any deep copy made from the original (see the Clone method). 這是設計所設計,而且在套用至模式有用的案例時,也會說明任何衍生類別的行為 Freezable 。This is by design and is how any derived class should behave when applied to the cases where the Freezable pattern is useful.