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,此方法返回true如果指定Freezable可变为不可修改,或false如果不能将其变为不可修改。If isChecking is true, this method returns true if the specified Freezable can be made unmodifiable, or false if it cannot be made unmodifiable. 如果isCheckingfalse,此方法返回true如果指定Freezable目前已经不可修改,或false如果不能将其变为不可修改。If 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.

另请参阅

适用于