public void Undo()
{
if (isAdd)
{
if (collection is IDictionary)
{
obj = ((IDictionary)collection)[key];
((IDictionary)collection).Remove(key);
}
else if (collection is IList)
{
obj = ((IList)collection)[(int)key];
((IList)collection).RemoveAt((int)key);
}
}
else
{
if (collection is IDictionary)
{
((IDictionary)collection).Add(key, obj);
obj = null;
}
else if (collection is IList)
{
((IList)collection).Insert((int)key, obj);
obj = null;
}
}
isAdd = !isAdd;
}