ISessionStateItemCollection Arabirim

Tanım

Oturumu yönetmek için ASP.NET oturum durumu tarafından kullanılan koleksiyonun sözleşmesini tanımlar.

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
Türetilmiş
Uygulamalar

Örnekler

Aşağıdaki kod örneği, oturum durumu değişken adlarını ve değerlerini depolamak için ve sınıfını kullanır 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

Açıklamalar

arabirimi, ISessionStateItemCollection sınıf tarafından uygulama koduna sunulan oturum öğelerinin HttpSessionStateContainer koleksiyonunu tanımlar.

arabiriminin ISessionStateItemCollection ASP.NET uygulaması sınıfıdırSessionStateItemCollection.

Oturum verilerini depolamak için sınıfından SessionStateStoreProviderBase türetilmiş bir sınıf oluşturursanız, depolanmış nesneleri yönetmek için sınıfını kullanabilir SessionStateItemCollection veya arabirimini kendi koleksiyon yöneticinize uygulayabilirsiniz ISessionStateItemCollection .

Arabirimini uygularsanız ISessionStateItemCollection , oturum değişkenlerini SessionStateStoreProviderBase yönetmek için uygulamanızı ISessionStateItemCollection kullanmak için sınıfını devralan bir sınıf da oluşturmanız gerekir.

Bir ISessionStateItemCollection uygulama, arabirimin üyelerini ICollection de uygulamalıdır.

Özellikler

Count

ICollection içindeki öğe sayısını alır.

(Devralındığı yer: ICollection)
Dirty

Koleksiyonun değiştirilmiş olarak işaretlenip işaretlenmediğini belirten bir değer alır veya ayarlar.

IsSynchronized

erişimin ICollection eşitlenip eşitlenmediğini belirten bir değer alır (iş parçacığı güvenli).

(Devralındığı yer: ICollection)
Item[Int32]

Koleksiyondaki bir değeri sayısal dizine göre alır veya ayarlar.

Item[String]

Koleksiyondaki bir değeri ada göre alır veya ayarlar.

Keys

Koleksiyonda depolanan tüm değerler için değişken adlarının bir koleksiyonunu alır.

SyncRoot

erişimi ICollectioneşitlemek için kullanılabilecek bir nesnesi alır.

(Devralındığı yer: ICollection)

Yöntemler

Clear()

Oturum durumu koleksiyonundaki tüm değerleri ve anahtarları kaldırır.

CopyTo(Array, Int32)

öğesinin öğelerini ICollection belirli Array bir Arraydizinden başlayarak öğesine kopyalar.

(Devralındığı yer: ICollection)
GetEnumerator()

Bir toplulukta tekrarlanan bir numaralandırıcı döndürür.

(Devralındığı yer: IEnumerable)
Remove(String)

Bir öğeyi koleksiyondan siler.

RemoveAt(Int32)

Belirtilen dizindeki bir öğeyi koleksiyondan siler.

Uzantı Metotları

Cast<TResult>(IEnumerable)

öğesinin IEnumerable öğelerini belirtilen türe atar.

OfType<TResult>(IEnumerable)

Bir öğesinin IEnumerable öğelerini belirtilen türe göre filtreler.

AsParallel(IEnumerable)

Sorgunun paralelleştirilmesini sağlar.

AsQueryable(IEnumerable)

bir IEnumerable öğesini öğesine IQueryabledönüştürür.

Şunlara uygulanır

Ayrıca bkz.