示例#1
0
        bool IEnumerator.MoveNext()
        {
            bool moved = false;

            while (true)
            {
                if (enumerator.MoveNext())
                {
                    IEnumerator e   = this as IEnumerator;
                    tgEntity    obj = e.Current as tgEntity;

                    if (obj.rowState != tgDataRowState.Deleted)
                    {
                        moved = true;
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            return(moved);
        }
        private SortedList GetSortedListOfProperties(tgEntity entity, tgEntityCollectionBase baseCollection)
        {
            SortedList list = new SortedList();

            tgEntityCollectionBase theBaseCollection = baseCollection != null ? baseCollection : entity.Collection;

            if (theBaseCollection != null)
            {
                if (theBaseCollection.selectedColumns != null)
                {
                    foreach (KeyValuePair <string, int> selectedColumn in theBaseCollection.selectedColumns)
                    {
                        list.Add(selectedColumn.Value, selectedColumn.Key);
                    }
                }

                if (theBaseCollection.extraColumnMetadata != null)
                {
                    foreach (KeyValuePair <string, tgColumnMetadata> extraColumn in theBaseCollection.extraColumnMetadata)
                    {
                        list.Add(extraColumn.Value.Ordinal, extraColumn.Key);
                    }
                }
            }

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

            entities.Remove((T)entity);

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

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

            if (updateViewNotification != null)
            {
                OnUpdateViewNotification(this, ListChangedType.ItemDeleted, entity);
            }
        }
示例#4
0
        public override void SetValue(object component, object value)
        {
            tgEntity obj = component as tgEntity;

            if (obj == null)
            {
                return;
            }

            if (_trueDescriptor != null)
            {
                _trueDescriptor.SetValue(component, value);
            }
            else
            {
                if (obj != null)
                {
                    if (m_setDelegate != null)
                    {
                        m_setDelegate(obj, value);
                    }
                    else
                    {
                        obj.currentValues[this.Name] = value;
                        obj.OnPropertyChanged(this.Name);
                    }
                }
            }
        }
示例#5
0
        public override object GetValue(object component)
        {
            tgEntity obj = component as tgEntity;

            if (obj == null)
            {
                return(null);
            }

            if (_trueDescriptor != null)
            {
                return(this._trueDescriptor.GetValue(component));
            }
            else
            {
                object o = null;

                if (m_getDelegate != null)
                {
                    o = m_getDelegate(component);
                }
                else
                {
                    obj.currentValues.TryGetValue(this.Name, out o);
                }

                return(o);
            }
        }
示例#6
0
 public tgPropertyDescriptor(tgEntity entity, string name, Type propertyType, tgEntity containedEntity)
     : base(name, null)
 {
     this._entity          = entity;
     this.m_propertyType   = propertyType;
     this._containedEntity = containedEntity;
 }
示例#7
0
        int IComparer <T> .Compare(T obj1, T obj2)
        {
            tgEntity         obj      = obj1 as tgEntity;
            tgColumnMetadata esColumn = obj.tg.Meta.Columns.FindByPropertyName(sortProperty.Name);

            return(obj1.OnSort(obj2, esColumn, sortProperty.Name));
        }
 protected void SetConnection(tgEntity entity)
 {
     if (!String.IsNullOrWhiteSpace(_connectionName))
     {
         entity.tg.Connection.Name = _connectionName;
     }
 }
示例#9
0
 public tgPropertyDescriptor(tgEntity entity, string name, Type propertyType, tgEntity containedEntity)
     : base(name, null)
 {
     this._entity = entity;
     this.m_propertyType = propertyType;
     this._containedEntity = containedEntity;
 }
示例#10
0
        static public jsColumn[] PopulateColumns(tgEntity entity)
        {
            List <jsColumn> cols = new List <jsColumn>();

            // we just put some fake data in the footer section for the demo
            decimal footer = 100M;

            List <string> columns = entity.GetCurrentListOfColumns();

            foreach (string column in columns)
            {
                tgColumnMetadata esCol = entity.tg.Meta.Columns.FindByColumnName(column);

                jsColumn c = new jsColumn();

                footer += 2M;

                if (esCol != null)
                {
                    c.isVisible          = true;
                    c.displayName        = esCol.PropertyName;
                    c.dataType           = esCol.Type.ToString();
                    c.columnName         = esCol.Name;
                    c.propertyName       = esCol.PropertyName;
                    c.ordinal            = esCol.Ordinal;
                    c.numericPrecision   = esCol.NumericPrecision;
                    c.numericScale       = esCol.NumericScale;
                    c.characterMaxLength = esCol.CharacterMaxLength;
                    c.defaultValue       = esCol.Default;
                    c.hasDefault         = esCol.HasDefault;
                    c.isInPrimaryKey     = esCol.IsInPrimaryKey;
                    c.isAutoIncrement    = esCol.IsAutoIncrement;
                    c.isNullable         = esCol.IsNullable;
                    c.isConcurrency      = esCol.IsConcurrency || esCol.IsTiraggoConcurrency;
                    c.isSortable         = true;
                    c.footerValue        = "$" + Convert.ToString(footer);
                }
                else
                {
                    object o = entity.GetColumn(column);

                    if (o != DBNull.Value && o != null)
                    {
                        c.dataType = o.GetType().ToString();
                    }

                    c.isVisible    = true;
                    c.displayName  = column;
                    c.columnName   = column;
                    c.propertyName = column;
                    c.isSortable   = false;
                    c.footerValue  = "$" + Convert.ToString(footer);
                }

                cols.Add(c);
            }

            return(cols.ToArray());
        }
示例#11
0
        public static jsColumn[] PopulateColumns(tgEntity entity)
        {
            List<jsColumn> cols = new List<jsColumn>();

            // we just put some fake data in the footer section for the demo
            decimal footer = 100M;

            List<string> columns = entity.GetCurrentListOfColumns();

            foreach (string column in columns)
            {
                tgColumnMetadata esCol = entity.tg.Meta.Columns.FindByColumnName(column);

                jsColumn c = new jsColumn();

                footer += 2M;

                if (esCol != null)
                {
                    c.isVisible = true;
                    c.displayName = esCol.PropertyName;
                    c.dataType = esCol.Type.ToString();
                    c.columnName = esCol.Name;
                    c.propertyName = esCol.PropertyName;
                    c.ordinal = esCol.Ordinal;
                    c.numericPrecision = esCol.NumericPrecision;
                    c.numericScale = esCol.NumericScale;
                    c.characterMaxLength = esCol.CharacterMaxLength;
                    c.defaultValue = esCol.Default;
                    c.hasDefault = esCol.HasDefault;
                    c.isInPrimaryKey = esCol.IsInPrimaryKey;
                    c.isAutoIncrement = esCol.IsAutoIncrement;
                    c.isNullable = esCol.IsNullable;
                    c.isConcurrency = esCol.IsConcurrency || esCol.IsEntitySpacesConcurrency;
                    c.isSortable = true;
                    c.footerValue = "$" + Convert.ToString(footer);
                }
                else
                {
                    object o = entity.GetColumn(column);

                    if (o != DBNull.Value && o != null)
                    {
                        c.dataType = o.GetType().ToString();
                    }

                    c.isVisible = true;
                    c.displayName = column;
                    c.columnName = column;
                    c.propertyName = column;
                    c.isSortable = false;
                    c.footerValue = "$" + Convert.ToString(footer);
                }

                cols.Add(c);
            }

            return cols.ToArray();
        }
示例#12
0
        void IList.Remove(object value)
        {
#if (TRACE)
            Console.WriteLine("void IList.Remove(object value)");
#endif
            tgEntity entity = value as tgEntity;

            entities.Remove((T)entity);

            entity.MarkAsDeleted();

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

            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
            tgEntity entity = ((IList)entities)[index] as tgEntity;

            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);
            }
        }
示例#15
0
        bool ICollection <T> .Remove(T item)
        {
#if (TRACE)
            Console.WriteLine("bool ICollection<T>.Remove(T item)");
#endif
            tgEntity entity = item as tgEntity;

            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
            tgEntity entity = item as tgEntity;

            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);
        }
示例#17
0
 virtual internal PropertyDescriptorCollection GetProperties(tgEntity entity, tgEntityCollectionBase baseCollection)
 {
     return(null);
 }
示例#18
0
        public void OnUpdateViewEventHandler(object sender, ListChangedType changeType, tgEntity entity)
        {
            bool orginal = this.entities.RaiseListChangedEvents;

            this.entities.RaiseListChangedEvents = collection.RaiseListChangeEventsEnabled;

            switch (changeType)
            {
            case ListChangedType.ItemDeleted:
            {
                IList coll = this as IList;
                coll.Remove(entity);

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

            case ListChangedType.ItemAdded:
            {
                IList coll = this as IList;
                coll.Add(entity);

                if (entitiesFilterBackup != null)
                {
                    IBindingList i = entitiesFilterBackup as IBindingList;
                    i.Add(entity);
                }
            }
            break;

            case ListChangedType.Reset:
            {
                entities.Clear();

                // We want to initially populate from the original list if there is an ongoing filer ..
                BindingList <T> list = (collection.entitiesFilterBackup == null) ? baseEntityList : collection.entitiesFilterBackup;

                foreach (T obj in list)
                {
                    entities.Add(obj);
                }

                if (entitiesFilterBackup != null)
                {
                    entitiesFilterBackup = null;
                }
            }
            break;
            }

            this.entities.RaiseListChangedEvents = orginal;
        }
示例#19
0
 public tgPropertyDescriptor(tgEntity entity, string name, Type propertyType)
     : base(name, null)
 {
     this._entity        = entity;
     this.m_propertyType = propertyType;
 }
        PropertyDescriptorCollection ITypedList.GetItemProperties(PropertyDescriptor[] listAccessors)
        {
            // We are binding so we turn this on ...
            entities.RaiseListChangedEvents = true;

            PropertyDescriptorCollection props = null;
            Type type = null;

            if (listAccessors == null || listAccessors.Length == 0)
            {
                tgEntity e = null;

                // It wants "this" object and so we can use this technique
                if (this.Count > 0)
                {
                    e = entities[0] as tgEntity;
                }
                else
                {
                    e = new T();
                }

                type = e.GetType();

                //------------------------------------
                // Check to see if it's in the cached
                //------------------------------------
                if (this.BindingPropertyCache.ContainsKey(type))
                {
                    return(this.BindingPropertyCache[type]);
                }

                props = this.GetProperties(e, this);

                this.BindingPropertyCache[type] = props;
            }
            else
            {
                if (this.EnableHierarchicalBinding == false)
                {
                    return(null);
                }

                // We should not enter this else statement if hierarchical binding is false
                PropertyDescriptor prop = listAccessors[listAccessors.Length - 1];

                //------------------------------------
                // Check to see if it's in the cached
                //------------------------------------
                if (this.BindingPropertyCache.ContainsKey(prop.PropertyType))
                {
                    return(this.BindingPropertyCache[prop.PropertyType]);
                }

                tgPropertyDescriptor esProp = prop as tgPropertyDescriptor;

                if (esProp != null)
                {
                    // Nope, not in the cache, let's get the info
                    props = this.GetProperties(esProp.ContainedEntity, null);
                }
                else
                {
                    // I give up, go get the raw properties
                    props = TypeDescriptor.GetProperties(prop.PropertyType);
                }

                this.BindingPropertyCache[prop.PropertyType] = props;
            }

            return(props);
        }
        internal override PropertyDescriptorCollection GetProperties(tgEntity entity, tgEntityCollectionBase baseCollection)
        {
            bool weHaveData  = false;
            int  lastOrdinal = 0;

            tgColumnMetadataCollection esMetaCols = entity.tg.Meta.Columns;

            tgEntityCollectionBase theBaseCollection = baseCollection != null ? baseCollection : entity.Collection;

            bool enableHierarchcialBinding = theBaseCollection != null ? theBaseCollection.EnableHierarchicalBinding : true;

            if (theBaseCollection != null)
            {
                if (theBaseCollection.GetList() != null)
                {
                    // Do we have any entities?
                    weHaveData = theBaseCollection.GetList().Count > 0;

                    if (weHaveData == false)
                    {
                        // If selectedColumns has data then they attempted a load and we know the columns based on thier select statement
                        weHaveData = theBaseCollection.selectedColumns != null && theBaseCollection.selectedColumns.Keys.Count > 0;
                    }
                }
            }

            //------------------------------------------------------------
            // First we deal with Properties from the DataTable.Columns
            // or from the tgColumnMetadataCollection.
            //------------------------------------------------------------
            ArrayList collNested = new ArrayList();
            SortedList <int, PropertyDescriptor> coll = new SortedList <int, PropertyDescriptor>();

            PropertyDescriptorCollection props = TypeDescriptor.GetProperties(entity, true);

            // Note, we check for selectedColumns because we might be a deserialized collection in which
            // case there will not be any selectedColumns
            if (weHaveData && theBaseCollection.selectedColumns != null)
            {
                SortedList list = GetSortedListOfProperties(entity, baseCollection);

                for (int i = 0; i < list.Count; i++)
                {
                    string column = (string)list.GetByIndex(i);

                    if (column == "ESRN")
                    {
                        continue;
                    }

                    tgColumnMetadata esCol = entity.tg.Meta.Columns.FindByColumnName(column);

                    if (esCol != null)
                    {
                        PropertyDescriptor prop = props[esCol.PropertyName];

                        if (prop != null)
                        {
                            coll.Add(lastOrdinal++, prop);
                        }
                    }
                    else
                    {
                        esCol = theBaseCollection.extraColumnMetadata[column];

                        if (esCol != null)
                        {
                            // Extra or Extended Properties
                            tgPropertyDescriptor dpd = new tgPropertyDescriptor
                                                       (
                                typeof(T),
                                column,
                                esCol != null ? esCol.Type : typeof(string),
                                delegate(object p)
                            {
                                return(((tgEntity)p).currentValues[column]);
                            },
                                delegate(object p, object data)
                            {
                                ((tgEntity)p).currentValues[column] = data;
                                ((tgEntity)p).OnPropertyChanged(column);
                            }
                                                       );

                            coll.Add(lastOrdinal++, dpd);
                        }
                    }
                }
            }
            else
            {
                foreach (tgColumnMetadata esCol in esMetaCols)
                {
                    coll.Add(lastOrdinal++, props[esCol.PropertyName]);
                }
            }

            //------------------------------------------------------------
            // Now we deal with extended properties that are using the
            // esExtendedPropertyAttribute technique
            //------------------------------------------------------------
            foreach (PropertyDescriptor prop in props)
            {
                if (prop.Attributes.Contains(tgEntityCollection <T> .extendedPropertyAttribute))
                {
                    coll.Add(lastOrdinal++, prop);
                }
            }

            //------------------------------------------------------------
            // Now we deal with any local properties. Local properties are
            // properties that users may want to bind with that are
            // NOT backed by data in the DataTable
            //------------------------------------------------------------
            List <tgPropertyDescriptor> localProps = entity.GetLocalBindingProperties();

            if (localProps != null)
            {
                foreach (tgPropertyDescriptor esProp in localProps)
                {
                    // We check this incase they add a local based property for a DataColumn
                    // based property, they would do this so it appears in design time, and
                    // we don't want to add a duplicate
                    bool exists = coll.ContainsValue(props[esProp.Name]);

                    if (!exists)
                    {
                        if (props[esProp.Name] != null)
                        {
                            coll.Add(lastOrdinal++, props[esProp.Name]);
                        }
                        else
                        {
                            coll.Add(lastOrdinal++, esProp);
                        }
                    }
                }
            }

            ArrayList tempColl = new ArrayList();

            if (enableHierarchcialBinding)
            {
                List <tgPropertyDescriptor> hierProps = entity.GetHierarchicalProperties();
                if (hierProps != null)
                {
                    foreach (tgPropertyDescriptor esProp in hierProps)
                    {
                        esProp.TrueDescriptor = props[esProp.Name];
                        //  coll.Add(lastOrdinal++, esProp);

                        tempColl.Add(esProp);
                    }
                }
            }

            // Create the collection
            foreach (PropertyDescriptor p in coll.Values)
            {
                tempColl.Add(p);
            }
            tempColl.AddRange(collNested);

            PropertyDescriptorCollection theProps =
                new PropertyDescriptorCollection((PropertyDescriptor[])tempColl.ToArray(typeof(PropertyDescriptor)));

            return(theProps);
        }
示例#22
0
 internal virtual void RemoveEntity(tgEntity entity)
 {
 }
示例#23
0
 public tgPropertyDescriptor(tgEntity entity, string name, Type propertyType)
     : base(name, null)
 {
     this._entity = entity;
     this.m_propertyType = propertyType;
 }
示例#24
0
 internal virtual void OnUpdateViewNotification(object sender, ListChangedType changeType, tgEntity obj)
 {
 }
示例#25
0
 internal virtual void AddEntityToDeletedList(tgEntity entity)
 {
 }
示例#26
0
 internal virtual PropertyDescriptorCollection GetProperties(tgEntity entity, tgEntityCollectionBase baseCollection)
 {
     return null;
 }
示例#27
0
 virtual internal void AddEntityToDeletedList(tgEntity entity)
 {
 }
示例#28
0
 internal virtual void RemoveEntity(tgEntity entity)
 {
 }
示例#29
0
 virtual internal void OnUpdateViewNotification(object sender, ListChangedType changeType, tgEntity obj)
 {
 }