Freezable.IsFrozen Freezable.IsFrozen Freezable.IsFrozen Freezable.IsFrozen Property

定义

获取一个值,该值指示对象当前是否可修改。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;如果可以修改该对象,则为 falsetrue 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. 若要设置此属性的值, 应调用FreezeTo 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.

适用于