DataSourceCacheDurationConverter クラス
アセンブリ: System.Web (system.web.dll 内)


キャッシュをサポートする ASP.NET データ ソース コントロールには、通常、コントロールがデータをキャッシュする秒数を設定できる CacheDuration プロパティが用意されています。これらのキャッシュ コンテキストでは、値 0 は "無限" を表します。また、この明示的な変換は DataSourceCacheDurationConverter クラスで処理されます。
ページの開発者は、DataSourceCacheDurationConverter クラスを使用しません。キャッシュをサポートするデータ ソース コントロールを開発しているコントロールの開発者は、この種類のコンバータを TypeConverterAttribute 属性と共に使用して、カスタム データ ソース コントロールのキャッシュの存続期間の設定を表すプロパティを装飾します。

TypeConverterAttribute 属性を使用して、キャッシュをサポートするデータ ソース コントロールのプロパティを装飾する方法を次のコード例に示します。この例では、データ ソース コントロールはキャッシュのセマンティクスをサポートし、EnableCaching、CacheDuration、および CacheExpirationPolicy という、他の ASP.NET データ ソース コントロールに即してモデル化された 3 つのプロパティを公開します。CacheDuration プロパティは、DataSourceCacheDurationConverter 型コンバータを使用します。
<NonVisualControl()> _ Public Class SomeDataSource Inherits DataSourceControl ' Implementation of a custom data source control. ' The SdsCache object is an imaginary cache object ' provided for this example. It has not actual ' implementation. Private myCache As New SdsCache() Friend ReadOnly Property Cache() As SdsCache Get Return myCache End Get End Property <TypeConverterAttribute(GetType(DataSourceCacheDurationConverter))> _ Public ReadOnly Property CacheDuration() As Integer Get Return Cache.Duration End Get End Property Public Property CacheExpirationPolicy() As DataSourceCacheExpiry Get Return Cache.Expiry End Get Set Cache.Expiry = value End Set End Property Public Property EnableCaching() As Boolean Get Return Cache.Enabled End Get Set Cache.Enabled = value End Set End Property Protected Overrides Function GetView(ByVal viewName As String) As System.Web.UI.DataSourceView Throw New Exception("The method or operation is not implemented.") End Function ' Continue implementation of data source control. ' ... End Class 'SomeDataSource
using System; using System.ComponentModel; using System.Web.UI; [ NonVisualControl() ] public class SomeDataSource : DataSourceControl { // Implementation of a custom data source control. // The SdsCache object is an imaginary cache object // provided for this example. It has not actual // implementation. private SdsCache m_sdsCache = new SdsCache(); internal SdsCache Cache { get { return m_sdsCache; } } [TypeConverterAttribute(typeof(DataSourceCacheDurationConverter))] public int CacheDuration { get { return Cache.Duration; } } public DataSourceCacheExpiry CacheExpirationPolicy { get { return Cache.Expiry; } set { Cache.Expiry = value; } } public bool EnableCaching { get { return Cache.Enabled; } set { Cache.Enabled = value; } } protected override DataSourceView GetView(string viewName) { throw new Exception("The method or operation is not implemented."); } // ... }


System.ComponentModel.TypeConverter
System.ComponentModel.BaseNumberConverter
System.ComponentModel.Int32Converter
System.Web.UI.DataSourceCacheDurationConverter


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DataSourceCacheDurationConverter クラスのページへのリンク