共用方式為


AggregateCacheDependency.GetUniqueID 方法

定義

擷取 AggregateCacheDependency 物件的唯一識別碼。

public:
 override System::String ^ GetUniqueID();
public override string GetUniqueID ();
override this.GetUniqueID : unit -> string
Public Overrides Function GetUniqueID () As String

傳回

AggregateCacheDependency 物件的唯一識別碼。 如果其中一個相關聯的相依性物件沒有唯一識別碼,則 GetUniqueID() 方法會傳回 null

範例

下列程式碼範例會 GetUniqueID 使用 方法來建立和顯示類別實例的 AggregateCacheDependency 識別碼,名稱 aggDep 為 ,一旦建立並填入。

         ' 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)

備註

這個方法會將唯一識別碼指派給陣列中的每個相依性,並傳回每個相依性。 識別碼是檔案相依性) 的檔案名 (的組合,或是快取) 金鑰相依性 ( (,以及這個方法指派給相依性之字串的組合。

適用於