public static bool DiffTwoList <TEntity>(EntityList <TEntity> before, EntityList <TEntity> after, out BindingCollection <TEntity> add, out BindingCollection <TEntity> upd, out BindingCollection <TEntity> del) where TEntity : EntityBase <TEntity> { add = new BindingCollection <TEntity>(); upd = new BindingCollection <TEntity>(); del = new BindingCollection <TEntity>(); if ((before == null) && (after != null)) { add = after.Entities; } else if ((before != null) && (after == null)) { del = before.Entities; } else if ((before != null) && (after != null)) { del = new BindingCollection <TEntity>(before.Entities.Except(after.Entities, new EntityIdComparer <TEntity>()).ToList <TEntity>()); foreach (TEntity entity in after.Entities.Except(before.Entities, new EntityFullComparer <TEntity>())) { if (entity.IsNewEntity) { add.Add(entity); } else { upd.Add(entity); } } } return(add.Count == 0 && upd.Count == 0 && del.Count == 0); }
public void Fill(BindingCollection <T> newList) { if (newList == null) { _Entitys = new BindingCollection <T>(); } else { _Entitys = newList; } if (_Entitys.Count == 0 || _Entitys.IndexOf(Current) == -1) { Current = null; } else { Current = Current; } if (_BindingSource != null) { _BindingSource.DataSource = Entities; int pos = _Entitys.IndexOf(Current); _BindingSource.Position = pos; } }
public BindingCollection(BindingCollection <T> list) : base(list) { IBindingList asBindingList = list as IBindingList; if (asBindingList != null) { asBindingList.ListChanged += SourceListChanged; } }
public EntityList(List <T> list) { if (list == null) { _Entitys = new BindingCollection <T>(); } else { _Entitys = new BindingCollection <T>(list); } if (_Entitys.Count > 0) { Current = _Entitys[0]; } }
public static BindingCollection <TEntity> DiffTwoListAndGetDel <TEntity>(EntityList <TEntity> before, EntityList <TEntity> after) where TEntity : EntityBase <TEntity> { BindingCollection <TEntity> result = new BindingCollection <TEntity>(); if ((before != null) && (after == null)) { result = before.Entities; } else if ((before != null) && (after != null)) { result = new BindingCollection <TEntity>(before.Entities.Except(after.Entities, new EntityIdComparer <TEntity>()).ToList <TEntity>()); } return(result); }
public static BindingCollection <TEntity> DiffTwoListAndGetUpd <TEntity>(EntityList <TEntity> before, EntityList <TEntity> after) where TEntity : EntityBase <TEntity> { BindingCollection <TEntity> result = new BindingCollection <TEntity>(); if ((before != null) && (after != null)) { foreach (TEntity entity in after.Entities.Except(before.Entities, new EntityFullComparer <TEntity>())) { if (!entity.IsNewEntity) { result.Add(entity); } } } return(result); }
public EntityList <T> Clone() { BindingCollection <T> bindingListView = new BindingCollection <T>(); if (_Entitys != null) { foreach (T entity in _Entitys) { bindingListView.Add(entity.Clone()); } } EntityList <T> entityList = new EntityList <T>(bindingListView); if (Current != null) { entityList.Current = Current.Clone(); } entityList.Caption = Caption; return(entityList); }
public EntityList() { _Entitys = new BindingCollection <T>(); }