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 方法创建并显示类实例(名为 aggDep)的AggregateCacheDependency标识符,一旦创建并填充该实例。

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

注解

此方法将唯一标识符分配给数组中的每个依赖项,并返回其中每个依赖项。 标识符是文件依赖项) 的文件名 (或缓存密钥依赖项) (的键名称和此方法分配给依赖项的字符串的组合。

适用于