public virtual void AddToDictionary (object instance, object key, object item)
{
if (instance == null)
throw new ArgumentNullException ("instance");
var t = instance.GetType ();
if (t.IsGenericType)
instance.GetType ().GetMethod ("Add", t.GetGenericArguments ()).Invoke (instance, new object [] {key, item});
else
instance.GetType ().GetMethod ("Add", new Type [] {typeof (object), typeof (object)}).Invoke (instance, new object [] {key, item});
}