StaticSiteMapProvider.Clear 方法

定義

移除子系和父代網站導覽節點集合中的所有項目,這些網站導覽節點是 StaticSiteMapProvider 在維護其狀態時所追蹤。

protected:
 virtual void Clear();
protected virtual void Clear ();
abstract member Clear : unit -> unit
override this.Clear : unit -> unit
Protected Overridable Sub Clear ()

範例

下列程式碼範例示範如何覆寫 Clear 方法,以執行 類別所維護之狀態的其他清除。

此程式碼範例是提供給 類別之較大範例的 StaticSiteMapProvider 一部分。

   // Clean up any collections or other state that an instance of this may hold.
   virtual void Clear() override
   {
      System::Threading::Monitor::Enter( this );
      try
      {
         rootNode = nullptr;
         StaticSiteMapProvider::Clear();
      }
      finally
      {
         System::Threading::Monitor::Exit( this );
      }

   }


public:
// Clean up any collections or other state that an instance of this may hold.
protected override void Clear() {
    lock (this) {
        rootNode = null;
        base.Clear();
    }
}
' SiteMapProvider and StaticSiteMapProvider methods that this derived class must override.
'
' Clean up any collections or other state that an instance of this may hold.
Protected Overrides Sub Clear()
    SyncLock Me
        aRootNode = Nothing
        MyBase.Clear()
    End SyncLock
End Sub

備註

衍生自 類別的 StaticSiteMapProvider 類別可以覆寫 Clear 方法來執行額外的清除,視衍生類別所維護的狀態而定。

方法 Clear 不會重設方法期間 Initialize 初始化的狀態, 只會重設方法期間 BuildSiteMap 初始化的狀態。

適用於

另請參閱