请单击以进行评分并提供反馈
MSDN
MSDN Library
.NET 开发
先前版本
 UtcLastModified 属性
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
.NET Framework 类库
CacheDependency.UtcLastModified 属性

注意:此属性在 .NET Framework 2.0 版中是新增的。

获取依赖项的上次更改时间。

命名空间:System.Web.Caching
程序集:System.Web(在 system.web.dll 中)

Visual Basic(声明)
Public ReadOnly Property UtcLastModified As DateTime
Visual Basic(用法)
Dim instance As CacheDependency
Dim value As DateTime

value = instance.UtcLastModified
C#
public DateTime UtcLastModified { get; }
C++
public:
property DateTime UtcLastModified {
    DateTime get ();
}
J#
/** @property */
public DateTime get_UtcLastModified ()
JScript
public function get UtcLastModified () : DateTime

属性值

依赖项的上次更改时间。

此属性以协调通用时间 (UTC)(也称为格林尼治标准时间)测量。

下面的代码示例使用 AggregateCacheDependency 类将一个具有两个 CacheDependency 对象依赖项的项添加到 Cache。请求 Cache 项时,该代码检查该项是否处于 Cache 中。如果是,则 UtcLastModified 属性转换为字符串并显示在页上。如果不是,则创建该项及其两个依赖项并将它们添加到 Cache

Visual Basic
' When the page is loaded, use the 
' AggregateCacheDependency class to make 
' a cached item dependent on two files.

Sub Page_Load(sender As Object, e As EventArgs)
   Dim Source As DataView

   Source = Cache("XMLDataSet")

   If Source Is Nothing
          Dim DS As New DataSet
          Dim FS As FileStream
          Dim Reader As StreamReader
          Dim txtDep As CacheDependency
          Dim xmlDep As CacheDependency
          Dim aggDep As AggregateCacheDependency


          FS = New FileStream(Server.MapPath("authors.xml"),FileMode.Open,FileAccess.Read)
          Reader = New StreamReader(FS)
          DS.ReadXml(Reader)
          FS.Close()

          Source = new DataView(ds.Tables(0))
         ' 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)
          If aggDep.HasChanged = True Then
             chngMsg.Text = "The dependency changed at: " & DateTime.Now

          Else
             chngMsg.Text = "The dependency changed last at: " & aggDep.UtcLastModified.ToString()
          End If


          cacheMsg1.Text = "Dataset created explicitly"
        Else
          cacheMsg1.Text = "Dataset retrieved from cache"
        End If


          MyLiteral.Text = Source.Table.TableName
          MyDataGrid.DataSource = Source
          MyDataGrid.DataBind()
      End Sub

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

.NET Framework

受以下版本支持:2.0
社区内容   什么是社区内容?
添加新内容 RSS  批注
Processing
© 2008 Microsoft Corporation 版权所有。 保留所有权利  |  商标  |  隐私权声明
Page view tracker