コード例 #1
0
        private SortedList GetSortedListOfProperties(esEntity entity, esEntityCollectionBase baseCollection)
        {
            SortedList list = new SortedList();

            esEntityCollectionBase 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, esColumnMetadata> extraColumn in theBaseCollection.extraColumnMetadata)
                    {
                        list.Add(extraColumn.Value.Ordinal, extraColumn.Key);
                    }
                }
            }

            return(list);
        }
コード例 #2
0
        private void BindCollection(esEntityCollectionBase entities)
        {
            IEntityCollection entityCollection = (IEntityCollection) entities;
            CollectionDataGridView.DataSource = entities;

            if (entityCollection.Query != null && entityCollection.Query.es.LastQuery != null)
            {
                this.txtLastQuery.Text = entityCollection.Query.es.LastQuery;
            }
        }
コード例 #3
0
        static public void Map <T>(esEntityCollectionBase src, List <T> dst)
        {
            if (src != null && src.Count > 0 && dst != null && dst.Count > 0)
            {
                if (src.Count == dst.Count)
                {
                    IEnumerable iEnum = src as IEnumerable;
                    var         x     = iEnum.GetEnumerator();

                    int i = 0;
                    foreach (esEntity entity in iEnum)
                    {
                        esSmartDto dto = dst[i++] as esSmartDto;
                        dto.HrydateFromEntity(entity);
                    }
                }
            }
        }
コード例 #4
0
 virtual internal PropertyDescriptorCollection GetProperties(esEntity entity, esEntityCollectionBase baseCollection)
 {
     return(null);
 }
コード例 #5
0
        internal override PropertyDescriptorCollection GetProperties(esEntity entity, esEntityCollectionBase baseCollection)
        {
            bool weHaveData  = false;
            int  lastOrdinal = 0;

            esColumnMetadataCollection esMetaCols = entity.es.Meta.Columns;

            esEntityCollectionBase 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 esColumnMetadataCollection.
            //------------------------------------------------------------
            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;
                    }

                    esColumnMetadata esCol = entity.es.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
                            esPropertyDescriptor dpd = new esPropertyDescriptor
                                                       (
                                typeof(T),
                                column,
                                esCol != null ? esCol.Type : typeof(string),
                                delegate(object p)
                            {
                                return(((esEntity)p).currentValues[column]);
                            },
                                delegate(object p, object data)
                            {
                                ((esEntity)p).currentValues[column] = data;
                                ((esEntity)p).OnPropertyChanged(column);
                            }
                                                       );

                            coll.Add(lastOrdinal++, dpd);
                        }
                    }
                }
            }
            else
            {
                foreach (esColumnMetadata 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(esEntityCollection <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 <esPropertyDescriptor> localProps = entity.GetLocalBindingProperties();

            if (localProps != null)
            {
                foreach (esPropertyDescriptor 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 <esPropertyDescriptor> hierProps = entity.GetHierarchicalProperties();
                if (hierProps != null)
                {
                    foreach (esPropertyDescriptor 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);
        }
コード例 #6
0
 public esVisualizerForm(esEntityCollectionBase entities)
 {
     InitializeComponent();
     BindCollection(entities);
 }
コード例 #7
0
        public esColumnMetadataCollection GetColumns(esEntityCollectionBase collection)
        {
            collection.EnableHierarchicalBinding = false;

            PropertyDescriptorCollection props = null;

            try
            {
                MethodInfo GetEntity = collection.GetType().GetMethod("CreateEntity", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                esEntity entity = GetEntity.Invoke(collection, null) as esEntity;

                MethodInfo GetProperties = collection.GetType().GetMethod("GetProperties", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                props = GetProperties.Invoke(collection, new object[] { entity }) as PropertyDescriptorCollection;
            }
            catch { }

            MethodInfo get_Meta = collection.GetType().GetMethod("get_Meta", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            IMetadata meta = get_Meta.Invoke(collection, null) as IMetadata;
            esColumnMetadataCollection esColumns =  meta.Columns;

            esColumnMetadataCollection esCollection = new esColumnMetadataCollection();
            try
            {
                foreach (esColumnMetadata col in esColumns)
                {
                    esCollection.Add(col);
                }
            }
            catch { }

            try
            {
                if (props != null)
                {
                    esExtendedPropertyAttribute att = new esExtendedPropertyAttribute();
                    foreach (PropertyDescriptor prop in props)
                    {
                        if (esColumns.FindByPropertyName(prop.Name) == null)
                        {
                            if (prop.Attributes.Contains(att))
                            {
                                esColumnMetadata col = new esColumnMetadata(prop.Name, 1000, prop.PropertyType);
                                col.PropertyName = prop.Name;
                                esCollection.Add(col);
                            }
                        }
                    }
                }
            }
            catch { }

            return esCollection;
        }
コード例 #8
0
 internal virtual PropertyDescriptorCollection GetProperties(esEntity entity, esEntityCollectionBase baseCollection)
 {
     return null;
 }