Freezable.IsFrozen 属性


获取一个值,该值指示对象当前是否可修改。Gets a value that indicates whether the object is currently modifiable.

 property bool IsFrozen { bool get(); };
public bool IsFrozen { get; }
member this.IsFrozen : bool
Public ReadOnly Property IsFrozen As Boolean



如果该对象已被冻结且无法修改,则为 true;如果可以修改该对象,则为 falsetrue if the object is frozen and cannot be modified; false if the object can be modified.


当对象的属性引发时,尝试修改该对象 IsFrozen true InvalidOperationExceptionAttempting to modify an object when its IsFrozen property is true throws an InvalidOperationException.

从对象模型的角度来看,此属性是只读的。This property is read-only from the object model perspective. Freezable 讨论的其他方法的行为时,某些行为相关的文档可能会提到 "设置 IsFrozentrue " 或类似的语言 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. 若要设置此属性的值,应调用 FreezeTo set the value of this property, you should call Freeze. 这实际上只是一次操作,用于将 IsFrozen 属性从初始默认状态更改 falsetrue 状态。This effectively is a one-time operation to change the IsFrozen property from the initial default false state to the true state. 没有将值设置回的可用方法 falseThere 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). 这是设计使然,并且是在应用于模式有用情况时,派生类的行为方式 FreezableThis is by design and is how any derived class should behave when applied to the cases where the Freezable pattern is useful.