/// <summary> /// Update data in all access contexts from a secific proxy table. /// The method was called from an access context after commit local changes to synchronize local view data. /// </summary> /// <param name="instance">originator proxy table instance</param> internal void UpdateNotifyOtherListInstances(AccessContextList instance) { foreach (AccessContext context in this) { foreach (AccessContextList list in context.Tables) { if (list.DataSource == instance.DataSource && list != instance) { list.UpdateFromOtherInstance(instance); } } } }
/// <summary> /// Update the instance data from another AccessContextList instance. /// The method was called after commit changes from another access context to synchronize view data. /// </summary> /// <param name="instance">other access context list from different access context</param> internal void UpdateFromOtherInstance(AccessContextList instance) { if (this == instance) { throw new InvalidOperationException(); } foreach (var item in instance.ItemManager.Items) { switch (item.Key.State) { case AccessContextListItemManager.ItemEntryState.New: int newIndex = this.Count - ItemManager.NewCount; AccessContextItem newContextItem = new AccessContextItem(this, item.Key.Item.DataSource, AccessContextItemState.ItemIsNormal); InsertItemSilent(newIndex, newContextItem); break; case AccessContextListItemManager.ItemEntryState.Deleted: AccessContextItem deleteItem = GetItemFromDataSource(item.Key.Item.DataSource); if (null == deleteItem) { deleteItem = ItemManager.GetItemFromDataSource(item.Key.Item.DataSource); if (null != deleteItem) { deleteItem.ItemState = AccessContextItemState.ItemIsDeleted; ItemManager.RemoveItem(deleteItem); } continue; } deleteItem.ItemState = AccessContextItemState.ItemIsDeleted; int deleteIndex = IndexOf(deleteItem); RemoveSilent(deleteItem); ItemManager.DecrementItemIndex(deleteIndex); break; case AccessContextListItemManager.ItemEntryState.Changed: // do nothing break; default: throw new IndexOutOfRangeException(); } } }
/// <summary> /// Creates an instance of the class /// </summary> /// <param name="parent">parent list</param> public AccessContextListItemManager(AccessContextList parent) { Parent = parent; Items = new Dictionary <ItemEntry, int>(); }
/// <summary> /// Creates an instance of the class /// </summary> /// <param name="parent">parent list</param> /// <param name="state">current state of the item</param> public AccessContextItem(AccessContextList parent, AccessContextItemState state) { Parent = parent; ItemState = state; }
/// <summary> /// Creates an instance of the class /// </summary> /// <param name="parent">parent list</param> /// <param name="dataSource">origin item</param> /// <param name="state">current state of the item</param> public AccessContextItem(AccessContextList parent, RootItem dataSource, AccessContextItemState state) { Parent = parent; DataSource = dataSource; ItemState = state; }