영어로 읽기

다음을 통해 공유


ISessionStateItemCollection 인터페이스

정의

ASP.NET 세션 상태에서 세션을 관리하는 데 사용하는 컬렉션에 대한 계약을 정의합니다.

C#
public interface ISessionStateItemCollection : System.Collections.ICollection
파생
구현

예제

다음 코드 예제를 구현 합니다 ISessionStateItemCollection 및 사용 하 SortedList 여 세션 상태 변수 이름 및 값을 저장 하는 클래스입니다.

C#
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);
    }
  }
}

설명

합니다 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로 변환합니다.

적용 대상

제품 버전
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

추가 정보