AggregateCacheDependency.Add(CacheDependency[]) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將 CacheDependency 物件陣列新增至 AggregateCacheDependency 物件。
public:
void Add(... cli::array <System::Web::Caching::CacheDependency ^> ^ dependencies);
public void Add (params System.Web.Caching.CacheDependency[] dependencies);
member this.Add : System.Web.Caching.CacheDependency[] -> unit
Public Sub Add (ParamArray dependencies As CacheDependency())
參數
- dependencies
- CacheDependency[]
要新增的 CacheDependency 物件陣列。
例外狀況
CacheDependency 物件由超過一個以上的 Cache 項目參考。
範例
下列程式碼範例會 Add 使用 方法搭配 AggregateCacheDependency 建構函式來建立兩 CacheDependency 個 物件、將它們新增至名為 myDepArray
的陣列,然後讓快取中的專案相依于這兩 CacheDependency 個 CacheDependency 物件。
' Create two CacheDependency objects, one to a
' text file and the other to an XML file.
' Create a CacheDependency array with these
' two objects as items in the array.
txtDep = New CacheDependency(Server.MapPath("Storage.txt"))
xmlDep = New CacheDependency(Server.MapPath("authors.xml"))
Dim DepArray() As CacheDependency = {txtDep, xmlDep}
' Create an AggregateCacheDependency object and
' use the Add method to add the array to it.
aggDep = New AggregateCacheDependency()
aggDep.Add(DepArray)
' Call the GetUniqueId method to generate
' an ID for each dependency in the array.
msg1.Text = aggDep.GetUniqueId()
' Add the new data set to the cache with
' dependencies on both files in the array.
Cache.Insert("XMLDataSet", Source, aggDep)