ISessionStateItemCollectionとは? わかりやすく解説

ISessionStateItemCollection インターフェイス

メモ : このインターフェイスは、.NET Framework version 2.0新しく追加されたものです。

ASP.NET セッション状態セッション管理するために使用するコレクションコントラクト定義します

名前空間: System.Web.SessionState
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Interface ISessionStateItemCollection
    Inherits ICollection, IEnumerable
Dim instance As ISessionStateItemCollection
public interface ISessionStateItemCollection : ICollection, IEnumerable
public interface class ISessionStateItemCollection
 : ICollection, IEnumerable
public interface ISessionStateItemCollection extends ICollection,
 IEnumerable
public interface ISessionStateItemCollection extends
 ICollection, IEnumerable
解説解説

ISessionStateItemCollection インターフェイスは、HttpSessionStateContainer クラスによってアプリケーション コード公開されるセッション項目のコレクション定義します

ISessionStateItemCollection インターフェイスASP.NET実装は、SessionStateItemCollection クラスです。

SessionStateStoreProviderBase クラスから派生するクラス作成してセッション データ保存する場合は、SessionStateItemCollection クラス使用して保存されているオブジェクト管理するか、または各自コレクション マネージャISessionStateItemCollection インターフェイス実装ます。

ISessionStateItemCollection インターフェイス実装する場合は、ISessionStateItemCollection実装使用してセッション変数管理するために SessionStateStoreProviderBase クラス継承するクラス作成する必要があります

ISessionStateItemCollection実装は、ICollection インターフェイスメンバ実装する必要があります

使用例使用例

ISessionStateItemCollection実装し、SortedList クラス使用してセッション状態変数名と値を保存するコード例次に示します

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

  }

}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ISessionStateItemCollection メンバ
System.Web.SessionState 名前空間
その他の技術情報
ASP.NETセッション状態

ISessionStateItemCollection プロパティ


ISessionStateItemCollection メソッド


ISessionStateItemCollection メンバ



このページでは「.NET Framework クラス ライブラリ リファレンス」からISessionStateItemCollectionを検索した結果を表示しています。
Weblioに収録されているすべての辞書からISessionStateItemCollectionを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からISessionStateItemCollection を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ISessionStateItemCollection」の関連用語

ISessionStateItemCollectionのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ISessionStateItemCollectionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS