ISessionStateItemCollection 인터페이스

정의

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 경우 구현을 사용하여 ISessionStateItemCollection 세션 변수를 SessionStateStoreProviderBase 관리하려면 클래스를 상속하는 클래스도 만들어야 합니다.

구현은 ISessionStateItemCollection 인터페이스의 ICollection 멤버도 구현해야 합니다.

속성

Count

ICollection에 포함된 요소 수를 가져옵니다.

(다음에서 상속됨 ICollection)
Dirty

컬렉션이 변경되었다고 표시되었는지 여부를 나타내는 값을 가져오거나 설정합니다.

IsSynchronized

ICollection에 대한 액세스가 동기화되어 스레드로부터 안전하게 보호되는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ICollection)
Item[Int32]

숫자 인덱스별로 컬렉션의 값을 가져오거나 설정합니다.

Item[String]

이름별로 컬렉션의 값을 가져오거나 설정합니다.

Keys

컬렉션에 저장된 모든 값의 변수 이름 컬렉션을 가져옵니다.

SyncRoot

ICollection에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다.

(다음에서 상속됨 ICollection)

메서드

Clear()

세션 상태 컬렉션에서 모든 값과 키를 제거합니다.

CopyTo(Array, Int32)

특정 ICollection 인덱스부터 시작하여 Array의 요소를 Array에 복사합니다.

(다음에서 상속됨 ICollection)
GetEnumerator()

컬렉션을 반복하는 열거자를 반환합니다.

(다음에서 상속됨 IEnumerable)
Remove(String)

컬렉션에서 항목을 삭제합니다.

RemoveAt(Int32)

지정된 인덱스에 있는 항목을 컬렉션에서 삭제합니다.

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보