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;如果可以修改该对象,则为 falsetrue if the object is frozen and cannot be modified; false if the object can be modified.

注解

如果在 true IsFrozen 属性时尝试修改对象,则会引发 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 行为的文档可能会提到,在讨论其他 Freezable方法的行为时,"设置 IsFrozen true" 或类似的语言,但在类实例内部发生此行为,当实例操作抽象类中存在的私有变量。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.

适用于