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 物件,將其加入 CacheDependency 名為 myDepArray的陣列,然後讓快取中的項目依賴於這兩個 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)