本文整理匯總了C#中System.Web.SessionState.ISessionStateItemCollection接口的典型用法代碼示例。如果您正苦於以下問題:C# ISessionStateItemCollection接口的具體用法?C# ISessionStateItemCollection怎麽用?C# ISessionStateItemCollection使用的例子?那麽, 這裏精選的接口代碼示例或許可以為您提供幫助。
ISessionStateItemCollection接口屬於System.Web.SessionState命名空間,在下文中一共展示了ISessionStateItemCollection接口的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetEnumerator
//引入命名空間
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);
}
}
}