代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CrackSoft.Collections
{
class ItemEventArgs<TKey, TValue>: EventArgs
{
public KeyValuePair<TKey, TValue> Item
{
get;
set;
}
public ItemEventArgs(TKey key, TValue value)
{
Item = new KeyValuePair<TKey, TValue>(key, value);
}
}
class EventDictionary<TKey, TValue> : Dictionary<TKey, TValue>
{
public event EventHandler<ItemEventArgs<TKey, TValue>> ItemAdded;
public event EventHandler<ItemEventArgs<TKey, TValue>> ItemRemoved;
public new void Add(TKey key, TValue value)
{
base.Add(key, value);
if (ItemAdded != null)
ItemAdded(this, new ItemEventArgs<TKey, TValue>(key, value));
}
public new bool Remove(TKey key)
{
TValue value = base[key];
bool result = base.Remove(key);
if (result && ItemRemoved != null)
ItemRemoved(this, new ItemEventArgs<TKey, TValue>(key, value));
return result;
}
public new TValue this[TKey key]
{
get
{
return base[key];
}
set
{
bool exists = base.ContainsKey(key);
base[key] = value;
if (!exists && ItemAdded != null)
ItemAdded(this, new ItemEventArgs<TKey, TValue>(key, value));
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。