ISessionStateItemCollection Interface
Defines the contract for the collection used by ASP.NET session state to manage session.
Assembly: System.Web (in System.Web.dll)
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of elements contained in the ICollection.(Inherited from ICollection.) |
![]() | Dirty | Gets or sets a value indicating whether the collection has been marked as changed. |
![]() | IsSynchronized | Gets a value indicating whether access to the ICollection is synchronized (thread safe).(Inherited from ICollection.) |
![]() | Item(Int32) | Gets or sets a value in the collection by numerical index. |
![]() | Item(String) | Gets or sets a value in the collection by name. |
![]() | Keys | Gets a collection of the variable names for all values stored in the collection. |
![]() | SyncRoot | Gets an object that can be used to synchronize access to the ICollection.(Inherited from ICollection.) |
| Name | Description | |
|---|---|---|
![]() | Clear() | Removes all values and keys from the session-state collection. |
![]() | CopyTo(Array, Int32) | Copies the elements of the ICollection to an Array, starting at a particular Array index.(Inherited from ICollection.) |
![]() | GetEnumerator() | Returns an enumerator that iterates through a collection.(Inherited from IEnumerable.) |
![]() | Remove(String) | Deletes an item from the collection. |
![]() | RemoveAt(Int32) | Deletes an item at a specified index from the collection. |
| Name | Description | |
|---|---|---|
![]() | AsParallel() | Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.) |
![]() | AsQueryable() | Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.) |
![]() | Cast(Of TResult)() | Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.) |
![]() | OfType(Of TResult)() | Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.) |
The ISessionStateItemCollection interface defines the collection of session items exposed to application code by the HttpSessionStateContainer class.
The ASP.NET implementation of the ISessionStateItemCollection interface is the SessionStateItemCollection class.
If you create a class derived from the SessionStateStoreProviderBase class to store session data, you can either use the SessionStateItemCollection class to manage the stored objects or implement the ISessionStateItemCollection interface on your own collection manager.
If you implement the ISessionStateItemCollection interface, you must also create a class that inherits the SessionStateStoreProviderBase class in order to make use of your ISessionStateItemCollection implementation to manage session variables.
An ISessionStateItemCollection implementation must also implement the members of the ICollection interface.
The following code example implements the ISessionStateItemCollection and uses the SortedList class to store session-state variable names and values.
Imports System Imports System.Web Imports System.Web.SessionState Imports System.Collections Imports System.Collections.Specialized Namespace Samples.AspNet.Session Public Class MySessionStateItemCollection Implements ISessionStateItemCollection Private pItems As SortedList = New SortedList() Private pDirty As Boolean = False Public Property Dirty As Boolean Implements ISessionStateItemCollection.Dirty Get Return pDirty End Get Set pDirty = value End Set End Property Public Property Item(index As Integer) As Object Implements ISessionStateItemCollection.Item Get Return pItems(index) End Get Set pItems(index) = value pDirty = True End Set End Property Public Property Item(name As String) As Object Implements ISessionStateItemCollection.Item Get Return pItems(name) End Get Set pItems(name) = value pDirty = True End Set End Property Public ReadOnly Property Keys As NameObjectCollectionBase.KeysCollection _ Implements ISessionStateItemCollection.Keys Get Return CType(pItems.Keys, NameObjectCollectionBase.KeysCollection) End Get End Property Public ReadOnly Property Count As Integer Implements ICollection.Count Get Return pItems.Count End Get End Property Public ReadOnly Property SyncRoot As Object Implements ICollection.SyncRoot Get Return Me End Get End Property Public ReadOnly Property IsSynchronized As Boolean Implements ICollection.IsSynchronized Get Return False End Get End Property Public Function GetEnumerator() As IEnumerator Implements ICollection.GetEnumerator Return pItems.GetEnumerator() End Function Public Sub Clear() Implements ISessionStateItemCollection.Clear pItems.Clear() pDirty = True End Sub Public Sub Remove(name As String) Implements ISessionStateItemCollection.Remove pItems.Remove(name) pDirty = True End Sub Public Sub RemoveAt(index As Integer) Implements ISessionStateItemCollection.RemoveAt If index < 0 OrElse index >= Me.Count Then _ Throw New ArgumentOutOfRangeException("The specified index is not within the acceptable range.") pItems.RemoveAt(index) pDirty = True End Sub Public Sub CopyTo(array As Array, index As Integer) Implements ICollection.CopyTo pItems.CopyTo(array, index) End Sub End Class End Namespace
Available since 2.0
.jpeg?cs-save-lang=1&cs-lang=vb)
.jpeg?cs-save-lang=1&cs-lang=vb)