ISessionStateItemCollection 인터페이스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ASP.NET 세션 상태에서 세션을 관리하는 데 사용하는 컬렉션에 대한 계약을 정의합니다.
public interface class ISessionStateItemCollection : System::Collections::ICollection
public interface ISessionStateItemCollection : System.Collections.ICollection
type ISessionStateItemCollection = interface
interface ICollection
interface IEnumerable
Public Interface ISessionStateItemCollection
Implements ICollection
- 파생
- 구현
예제
다음 코드 예제에서는 ISessionStateItemCollection 구현 하 고 세션 상태 변수 이름 및 값을 저장 하는 클래스를 사용 합니다 SortedList .
using System;
using System.Web;
using System.Web.SessionState;
using System.Collections;
using System.Collections.Specialized;
namespace Samples.AspNet.Session
{
public class MySessionStateItemCollection : ISessionStateItemCollection
{
private SortedList pItems = new SortedList();
private bool pDirty = false;
public bool Dirty
{
get { return pDirty; }
set { pDirty = value; }
}
public object this[int index]
{
get { return pItems[index]; }
set
{
pItems[index] = value;
pDirty = true;
}
}
public object this[string name]
{
get { return pItems[name]; }
set
{
pItems[name] = value;
pDirty = true;
}
}
public NameObjectCollectionBase.KeysCollection Keys
{
get { return (NameObjectCollectionBase.KeysCollection)pItems.Keys; }
}
public int Count
{
get { return pItems.Count; }
}
public Object SyncRoot
{
get { return this; }
}
public bool IsSynchronized
{
get { return false; }
}
public IEnumerator GetEnumerator()
{
return pItems.GetEnumerator();
}
public void Clear()
{
pItems.Clear();
pDirty = true;
}
public void Remove(string name)
{
pItems.Remove(name);
pDirty = true;
}
public void RemoveAt(int index)
{
if (index < 0 || index >= this.Count)
throw new ArgumentOutOfRangeException("The specified index is not within the acceptable range.");
pItems.RemoveAt(index);
pDirty = true;
}
public void CopyTo(Array array, int index)
{
pItems.CopyTo(array, index);
}
}
}
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
설명
인터페이스는 ISessionStateItemCollection 클래스에서 애플리케이션 코드에 노출되는 세션 항목의 컬렉션을 정의합니다 HttpSessionStateContainer .
ISessionStateItemCollection 인터페이스의 ASP.NET 구현은 SessionStateItemCollection 클래스입니다.
클래스에서 SessionStateStoreProviderBase 파생된 클래스를 만들어 세션 데이터를 저장하는 경우 클래스를 SessionStateItemCollection 사용하여 저장된 개체를 관리하거나 사용자 고유의 컬렉션 관리자에서 인터페이스를 ISessionStateItemCollection 구현할 수 있습니다.
인터페이스를 구현하는 경우 구현을 ISessionStateItemCollection 사용하여 SessionStateStoreProviderBase 세션 변수를 ISessionStateItemCollection 관리하기 위해 클래스를 상속하는 클래스도 만들어야 합니다.
구현은 ISessionStateItemCollection 인터페이스의 ICollection 멤버도 구현해야 합니다.
속성
| Name | Description |
|---|---|
| Count |
에 포함된 ICollection요소 수를 가져옵니다. (다음에서 상속됨 ICollection) |
| Dirty |
컬렉션이 변경된 것으로 표시되었는지 여부를 나타내는 값을 가져오거나 설정합니다. |
| IsSynchronized |
ICollection 대한 액세스가 동기화되는지 여부를 나타내는 값을 가져옵니다(스레드로부터 안전). (다음에서 상속됨 ICollection) |
| Item[Int32] |
숫자 인덱스로 컬렉션의 값을 가져오거나 설정합니다. |
| Item[String] |
이름으로 컬렉션의 값을 가져오거나 설정합니다. |
| Keys |
컬렉션에 저장된 모든 값에 대한 변수 이름의 컬렉션을 가져옵니다. |
| SyncRoot |
ICollection대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다. (다음에서 상속됨 ICollection) |
메서드
| Name | Description |
|---|---|
| Clear() |
세션 상태 컬렉션에서 모든 값과 키를 제거합니다. |
| CopyTo(Array, Int32) |
특정 ICollection 인덱스에서 시작하여 Array 요소를 Array복사합니다. (다음에서 상속됨 ICollection) |
| GetEnumerator() |
컬렉션을 반복하는 열거자를 반환합니다. (다음에서 상속됨 IEnumerable) |
| Remove(String) |
컬렉션에서 항목을 삭제합니다. |
| RemoveAt(Int32) |
컬렉션에서 지정된 인덱스의 항목을 삭제합니다. |
확장명 메서드
| Name | Description |
|---|---|
| AsParallel(IEnumerable) |
쿼리의 병렬 처리를 사용하도록 설정합니다. |
| AsQueryable(IEnumerable) |
IEnumerable IQueryable변환합니다. |
| Cast<TResult>(IEnumerable) |
IEnumerable 요소를 지정된 형식으로 캐스팅합니다. |
| OfType<TResult>(IEnumerable) |
지정된 형식에 따라 IEnumerable 요소를 필터링합니다. |