CustomErrorCollection.Clear 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
移除收藏中的所有 CustomError 物件。
public:
void Clear();
public void Clear();
member this.Clear : unit -> unit
Public Sub Clear ()
範例
以下程式碼範例將移除集合中CustomError的所有CustomErrorCollection物件。 參考課堂主題中的 CustomErrorCollection 程式碼範例,學習如何取得該集合。
// Using the Clear method.
if (!customErrorsSection.SectionInformation.IsLocked)
{
// Execute the Clear method.
customErrorsCollection.Clear();
configuration.Save();
}
' Using the Clear method.
If Not customErrorsSection.SectionInformation.IsLocked Then
' Execute the Clear method.
customErrorsCollection.Clear()
configuration.Save()
End If
備註
呼叫 Clear 該方法後更新設定檔的結果取決於所選擇的方法 ConfigurationSaveMode 。 要更新設定檔,你會使用以下兩種超載之一: Save 和 Save。
如果你使用 Save.method,會適用以下條件。
如果你傳遞一個 Full or Modified 參數值,那麼在當前階層層級的設定檔區段中會插入
clear一個clientTarget元素。若您傳遞 Minimal 參數值,則在當前階層層級的組態檔案中,會加入一系列
remove元素,並加到配置檔的 clientTarget Element(ASP.NET 設定架構)。 每個 Reference 都會移除階層add結構中父組態檔案中定義元素的所有參考。 當你使用 Minimal時,集合上還有一個額外的屬性會影響設定檔序列化的內容: EmitClear,預設是false序列化的。 適用條件如下。
此 Clear 方法實際上會 add 刪除設定檔中當前階層層級中定義 clientTarget 的元素。 它也會移除階層結構中父組態檔案中定義的 add 元素的所有參考。
Note
add這些元素不會從clientTarget父組態檔案的區塊中刪除。