Provides a type converter to convert 32-bit signed integer objects to and from data source control cache duration representations.
Assembly: System.Web (in System.Web.dll)
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _ <AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _ Public Class DataSourceCacheDurationConverter _ Inherits Int32Converter
Dim instance As DataSourceCacheDurationConverter
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class DataSourceCacheDurationConverter : Int32Converter
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)] [AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)] public ref class DataSourceCacheDurationConverter : public Int32Converter
public class DataSourceCacheDurationConverter extends Int32Converter
ASP.NET data source controls that support caching typically provide a CacheDuration property that you can set to the number of seconds that the control caches data. The value 0 represents "Infinite" in these caching contexts, and the DataSourceCacheDurationConverter class takes care of this explicit conversion.
Page developers do not use the DataSourceCacheDurationConverter class. Control developers who are developing data source controls that support caching use this type converter along with the TypeConverterAttribute attribute to decorate a property that represents a cache duration setting of a custom data source control.
The following code example demonstrates how you can decorate a property on a data source control that supports caching with a TypeConverterAttribute attribute. In this example, the data source control supports caching semantics and exposes three properties modeled after other ASP.NET data source controls: EnableCaching, CacheDuration, and CacheExpirationPolicy. The CacheDuration property uses the DataSourceCacheDurationConverter type converter.
<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."); } // ... }
-
AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
-
AspNetHostingPermission
for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System.ComponentModel.TypeConverter
System.ComponentModel.BaseNumberConverter
System.ComponentModel.Int32Converter
System.Web.UI.DataSourceCacheDurationConverter
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.