public void Clear() { foreach (IDictionary d in dictionaries.Values) { lock (d) { object[] args = { d }; ClearMethod.MakeGenericMethod(APIType(d)).Invoke(this, args); } INotifyCollectionChanged d1 = d as INotifyCollectionChanged; if (d1 != null) { d1.OnBatchCollectionChanged(); } } }
/// <returns>true if some changes have been made. This is used to indicate that XenObjectsUpdated should be fired by IXenConnection.</returns> public bool UpdateFrom(IXenConnection connection, IList <ObjectChange> changes) { Dictionary <IDictionary, object> tofire = new Dictionary <IDictionary, object>(); foreach (ObjectChange o in changes) { if (IgnoreObjectChange(o)) { continue; } IDictionary d = GetCollectionForType(o.type); if (d == null) { continue; } object[] args = { connection, d, o }; UpdateFromMethod.MakeGenericMethod(o.type).Invoke(this, args); tofire[d] = null; } bool result = false; foreach (IDictionary d in tofire.Keys) { INotifyCollectionChanged n = d as INotifyCollectionChanged; if (n != null) { n.OnBatchCollectionChanged(); } result = true; } return(result); }