Freezable.Freeze Freezable.Freeze Freezable.Freeze Freezable.Freeze Method

定义

使 Freezable 对象变为不可修改并将其 IsFrozen 属性设置为 true,或测试是否可将 Freezable 对象变为不可修改。Makes a Freezable object unmodifiable and sets its IsFrozen property to true, or tests whether a Freezable object can be made unmodifiable.

重载

Freeze() Freeze() Freeze() Freeze()

使当前对象不可修改,并且将其 IsFrozen 属性设置为 trueMakes the current object unmodifiable and sets its IsFrozen property to true.

Freeze(Freezable, Boolean) Freeze(Freezable, Boolean) Freeze(Freezable, Boolean)

如果 isChecking 参数为 true,则此方法指示是否可将指定的 Freezable 变为不可修改。If the isChecking parameter is true, this method indicates whether the specified Freezable can be made unmodifiable. 如果 isChecking 参数为 false,则此方法尝试将指定的 Freezable 变为不可修改,并指示操作是否成功。If the isChecking parameter is false, this method attempts to make the specified Freezable unmodifiable and indicates whether the operation succeeded.

Freeze() Freeze() Freeze() Freeze()

使当前对象不可修改,并且将其 IsFrozen 属性设置为 trueMakes the current object unmodifiable and sets its IsFrozen property to true.

public:
 void Freeze();
public void Freeze ();
member this.Freeze : unit -> unit
Public Sub Freeze ()

异常

注解

若要避免在调用此InvalidOperationException方法时出现的可能性, 请CanFreeze检查属性以确定是否Freezable可以在调用此方法之前将其变为不可修改。To avoid the possibility of an InvalidOperationException when calling this method, check the CanFreeze property to determine whether the Freezable can be made unmodifiable before calling this method.

继承者说明

此方法使用FreezeCore(Boolean)方法Freezable使不可修改。This method uses the FreezeCore(Boolean) method to make the Freezable unmodifiable. 若要修改冻结行为, 请FreezeCore(Boolean)重写方法。To modify freezing behavior, override the FreezeCore(Boolean) method.

另请参阅

Freeze(Freezable, Boolean) Freeze(Freezable, Boolean) Freeze(Freezable, Boolean)

如果 isChecking 参数为 true,则此方法指示是否可将指定的 Freezable 变为不可修改。If the isChecking parameter is true, this method indicates whether the specified Freezable can be made unmodifiable. 如果 isChecking 参数为 false,则此方法尝试将指定的 Freezable 变为不可修改,并指示操作是否成功。If the isChecking parameter is false, this method attempts to make the specified Freezable unmodifiable and indicates whether the operation succeeded.

protected public:
 static bool Freeze(System::Windows::Freezable ^ freezable, bool isChecking);
protected internal static bool Freeze (System.Windows.Freezable freezable, bool isChecking);
static member Freeze : System.Windows.Freezable * bool -> bool

参数

freezable
Freezable Freezable Freezable Freezable

要检查或要变为不可修改的对象。The object to check or make unmodifiable. 如果 isCheckingtrue,则检查此对象,以确定是否可将其变为不可修改。If isChecking is true, the object is checked to determine whether it can be made unmodifiable. 如果 isCheckingfalse,则在可能的情况下将此对象变为不可修改。If isChecking is false, the object is made unmodifiable, if possible.

isChecking
Boolean Boolean Boolean Boolean

若为 true,则返回是否可冻结对象的指示(不实际冻结对象);若为 false,则实际冻结对象。true to return an indication of whether the object can be frozen (without actually freezing it); false to actually freeze the object.

返回

isCheckingtrue 时,如果可以将指定的 Freezable 变为不可修改,则此方法返回 true;如果无法将其变为不可修改,则返回 falseIf isChecking is true, this method returns true if the specified Freezable can be made unmodifiable, or false if it cannot be made unmodifiable. isCheckingfalse 时,如果指定的 Freezable 目前已经不可修改,则此方法返回 true;如果无法将其变为不可修改,则返回 falseIf isChecking is false, this method returns true if the specified Freezable is now unmodifiable, or false if it cannot be made unmodifiable.

异常

如果 isCheckingfalse,则表明将 freezable 变为不可修改的尝试已失败;对象目前处于未知状态(可能已将其部分冻结)。When isChecking is false, the attempt to make freezable unmodifiable was unsuccessful; the object is now in an unknown state (it might be partially frozen).

注解

除非您是从Freezable派生的, 并且FreezeCore重写方法, 否则不要调用此方法。Do not call this method unless you are deriving from Freezable and overriding the FreezeCore method. 此方法可在FreezeCore方法中用于冻结自身Freezable对象的类数据成员。This method may be used in the FreezeCore method to freeze class data members that are themselves Freezable objects.

在已冻结 (不可修改) 的Freezable对象上, 可以再次调用此方法。It is alright to call this method again on a Freezable object that is already frozen (unmodifiable).

继承者说明

此方法使用FreezeCore(Boolean)方法Freezable使不可修改。This method uses the FreezeCore(Boolean) method to make the Freezable unmodifiable. 若要修改冻结行为, 请FreezeCore(Boolean)重写方法。To modify freezing behavior, override the FreezeCore(Boolean) method.

另请参阅

适用于