DataSourceCacheDurationConverter クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
32 ビット符号付き整数オブジェクトをデータ ソース管理のキャッシュ期間表現との間で変換する型コンバーターを提供します。
public ref class DataSourceCacheDurationConverter : System::ComponentModel::Int32Converter
public class DataSourceCacheDurationConverter : System.ComponentModel.Int32Converter
type DataSourceCacheDurationConverter = class
inherit Int32Converter
Public Class DataSourceCacheDurationConverter
Inherits Int32Converter
- 継承
例
次のコード例では、 TypeConverterAttribute 属性を使用したキャッシュをサポートするデータ ソース コントロールのプロパティを装飾する方法を示します。 この例では、データ ソース コントロールはキャッシュ セマンティクスをサポートし、他の ASP.NET データ ソース コントロールの後にモデル化された 3 つのプロパティ (EnableCaching、CacheDuration、および CacheExpirationPolicy) を公開しています。
CacheDuration プロパティは、DataSourceCacheDurationConverter型コンバーターを使用します。
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.");
}
// ...
}
<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
注釈
ASP.NET キャッシュをサポートするデータ ソース コントロールには、通常、CacheDuration プロパティが用意されています。このプロパティは、コントロールがデータをキャッシュする秒数に設定できます。 値 0 はこれらのキャッシュ コンテキストで "Infinite" を表し、 DataSourceCacheDurationConverter クラスはこの明示的な変換を処理します。
ページ開発者は、 DataSourceCacheDurationConverter クラスを使用しません。 キャッシュをサポートするデータ ソース コントロールを開発しているコントロール開発者は、この型コンバーターと TypeConverterAttribute 属性を使用して、カスタム データ ソース コントロールのキャッシュ期間設定を表すプロパティを装飾します。
コンストラクター
| 名前 | 説明 |
|---|---|
| DataSourceCacheDurationConverter() |
DataSourceCacheDurationConverter クラスの新しいインスタンスを初期化します。 |