Export (0) Print
Expand All

DataSourceCacheDurationConverter Class

Provides a type converter to convert 32-bit signed integer objects to and from data source control cache duration representations.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

'Declaration
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class DataSourceCacheDurationConverter _
	Inherits Int32Converter
'Usage
Dim instance As DataSourceCacheDurationConverter

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 

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft