Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
        public BindingCollection(BindingCollection <T> list)
            : base(list)
        {
            IBindingList asBindingList = list as IBindingList;

            if (asBindingList != null)
            {
                asBindingList.ListChanged += SourceListChanged;
            }
        }
Ejemplo n.º 4
0
 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];
     }
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 public EntityList()
 {
     _Entitys = new BindingCollection <T>();
 }