void IList.Remove(object value)
        {
#if (TRACE)
            Console.WriteLine("void IList.Remove(object value)");
#endif
            esEntity entity = value as esEntity;

            entities.Remove((T)entity);

            if (entity.RowState != esDataRowState.Deleted && entity.RowState != esDataRowState.Added)
            {
                entity.MarkAsDeleted();
            }

            if (entitiesFilterBackup != null)
            {
                IList i = entitiesFilterBackup as IList;
                i.Remove(entity);
            }

            if (updateViewNotification != null)
            {
                OnUpdateViewNotification(this, ListChangedType.ItemDeleted, entity);
            }
        }
Exemplo n.º 2
0
        void IList.RemoveAt(int index)
        {
#if (TRACE)
            Console.WriteLine("void IList.RemoveAt(int index)");
#endif
            esEntity entity = ((IList)entities)[index] as esEntity;

            entities.Remove((T)entity);

            entity.MarkAsDeleted();

            if (entitiesFilterBackup != null)
            {
                IList i = entitiesFilterBackup as IList;
                i.Remove(entity);
            }
        }
Exemplo n.º 3
0
        void IList.Remove(object value)
        {
#if (TRACE)
            Console.WriteLine("void IList.Remove(object value)");
#endif
            esEntity entity = value as esEntity;

            entities.Remove((T)entity);

            entity.MarkAsDeleted();

            if (entitiesFilterBackup != null)
            {
                IList i = entitiesFilterBackup as IList;
                i.Remove(entity);
            }
        }
        void IList.RemoveAt(int index)
        {
#if (TRACE)
            Console.WriteLine("void IList.RemoveAt(int index)");
#endif
            esEntity entity = ((IList)entities)[index] as esEntity;

            entities.Remove((T)entity);

            entity.MarkAsDeleted();

            if (entitiesFilterBackup != null)
            {
                IList i = entitiesFilterBackup as IList;
                i.Remove(entity);
            }

            if (updateViewNotification != null)
            {
                OnUpdateViewNotification(this, ListChangedType.ItemDeleted, entity);
            }
        }
Exemplo n.º 5
0
        bool ICollection <T> .Remove(T item)
        {
#if (TRACE)
            Console.WriteLine("bool ICollection<T>.Remove(T item)");
#endif
            esEntity entity = item as esEntity;

            IList list    = this as IList;
            bool  removed = list.Contains(item);

            entities.Remove((T)entity);

            entity.MarkAsDeleted();

            if (entitiesFilterBackup != null)
            {
                IList i = entitiesFilterBackup as IList;
                i.Remove(entity);
            }

            return(removed);
        }
        bool ICollection <T> .Remove(T item)
        {
#if (TRACE)
            Console.WriteLine("bool ICollection<T>.Remove(T item)");
#endif
            esEntity entity = item as esEntity;

            bool removed = entities.Remove((T)entity);

            entity.MarkAsDeleted();

            if (entitiesFilterBackup != null)
            {
                IList i = entitiesFilterBackup as IList;
                i.Remove(entity);
            }

            if (updateViewNotification != null)
            {
                OnUpdateViewNotification(this, ListChangedType.ItemDeleted, entity);
            }

            return(removed);
        }
        public override void Delete(System.Collections.IDictionary keys, System.Collections.IDictionary oldValues, DataSourceViewOperationCallback callback)
        {
            esDataSourceDeleteEventArgs e = null;

            try
            {
                if (keys != null && keys.Count > 0)
                {
                    e           = new esDataSourceDeleteEventArgs();
                    e.Keys      = keys;
                    e.OldValues = oldValues;

                    this.OnPreDelete(e);
                    if (e.Cancel)
                    {
                        return;
                    }

                    // Find the proper esEntity and set it's values
                    object[] pks = new object[keys.Count];

                    int index = 0;
                    foreach (object value in keys.Values)
                    {
                        pks[index++] = value;
                    }

                    esDataSourceCreateEntityEventArgs ce = new esDataSourceCreateEntityEventArgs();
                    ce.PrimaryKeys = pks;
                    this.OnCreateEntity(ce);

                    esEntity entity = ce.Entity;
                    e.Entity = entity;

                    //this.OnPreDelete(e);

                    e.EventWasHandled = false;
                    this.OnDelete(e);

                    if (!e.EventWasHandled)
                    {
                        entity.MarkAsDeleted();
                        entity.Save();

                        this.OnDataSourceViewChanged(EventArgs.Empty);
                    }

                    this.OnPostDelete(e);
                }
            }
            catch (Exception ex)
            {
                esDataSourceExceptionEventArgs exArgs = new esDataSourceExceptionEventArgs(ex);
                exArgs.EventType  = esDataSourceEventType.Delete;
                exArgs.DeleteArgs = e;

                try
                {
                    this.OnException(exArgs);
                }
                catch { }

                if (!exArgs.ExceptionWasHandled)
                {
                    throw;
                }
            }
            finally
            {
                callback(1, null);
            }
        }