/// <summary>
        /// Initializes a new instance of the <see cref="DataTableExtended"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="primaryKeyName">Name of the primary key - optionally.</param>
        /// <param name="title">The title.</param>
        /// <param name="description">The description.</param>
        public DataTableExtended(Type type, string title, String description = "") : base(title.getCleanPropertyName())
        {
            var settings = new settingsEntriesForObject(type, false);

            if (description.isNullOrEmpty())
            {
                description = settings.Description;
            }

            DataTableExtended table = this;

            table.settings = settings;

            table.SetClassType(type);
            table.SetClassName(type.Name);
            table.SetDescription(description);
            table.SetTitle(title);

            table.SetCategoryPriority(settings.CategoryByPriority);

            //table.PrimaryKey = new DataColumn[] { };

            foreach (settingsPropertyEntry spe in settings.spes.Values)
            {
                if (!spe.IsXmlIgnore)
                {
                    var column = table.Add(spe);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Gets the category priority.
        /// </summary>
        /// <param name="dc">The dc.</param>
        /// <returns></returns>
        public static List <string> GetCategoryPriority(this DataTable dc)
        {
            if (!dc.ExtendedProperties.ContainsKey(templateFieldDataTable.categoryPriority))
            {
                var output = new List <string>();

                Type t = dc.GetClassType();
                if (t != null)
                {
                    settingsEntriesForObject seo = new settingsEntriesForObject(t, false);
                    dc.SetCategoryPriority(seo.CategoryByPriority);
                }
                else
                {
                    List <string> cats = new List <string>();
                    foreach (DataColumn d in dc.Columns)
                    {
                        String cat = d.GetGroup();
                        if (cat != null)
                        {
                            cats.AddUnique(cat.ToUpper());
                        }
                    }
                    dc.SetCategoryPriority(cats);
                }
            }

            List <string> dcs   = dc.ExtendedProperties[templateFieldDataTable.categoryPriority] as List <string>;
            List <string> dcout = new List <string>();

            dcs.ForEach(x => dcout.AddUnique(x));

            return(dcs);
        }
        /// <summary>
        /// Builds the data table.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="columns">The columns.</param>
        /// <returns></returns>
        public static DataTable BuildDataShema(this object source, string[] columns, PropertyEntryColumn extraColumn, settingsEntriesForObject seo = null, DataTable dt = null)
        {
            if (seo == null)
            {
                seo = new settingsEntriesForObject(source);
            }

            if (dt == null)
            {
                dt = new DataTable(source.GetType().Name);
            }
            dt.ExtendedProperties[templateFieldDataTable.shema_sourceinstance] = source;
            dt.ExtendedProperties[templateFieldDataTable.shema_classname]      = source.GetType().Name;

            dt.ExtendedProperties[templateFieldDataTable.shema_dictionary] = source.buildPCE(true, null);

            if (extraColumn.HasFlag(PropertyEntryColumn.autocount_idcolumn))
            {
                dt.Columns.Add(IDCOLUMN).AutoIncrement = true;
            }

            foreach (string col in columns)
            {
                dt.AddToShema(col, source, seo);
            }

            return(dt);
        }
        public void refresh()
        {
            IEnumerable items = target.value as IEnumerable;

            menu = new aceMenu();

            menu.menuTitle       = "Inside " + target.pi.DeclaringType.Name + "->" + target.displayName + " collection";
            menu.menuDescription = "Collection type [" + target.pi.PropertyType.ToString() + "]";

            pageManager = new textPageManager <aceMenuItem>(10, 100, 1);

            itemSettings = null;

            Int32 c = 0;

            foreach (var t in items)
            {
                if (itemSettings == null)
                {
                    itemSettings = new settingsEntriesForObject(t);
                }
                var mi = new aceMenuItem(t.ToString(), c.ToString(), t.GetType().Name, "", t);
                menu.setItem(mi);
            }
        }
        /// <summary>
        /// Adds column using object <c>source</c> reflection information
        /// </summary>
        /// <param name="dt">The dt.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="source">The source.</param>
        /// <param name="seo">The seo.</param>
        /// <returns></returns>
        public static DataColumn AddToShema(this DataTable dt, string propertyName, object source = null, settingsEntriesForObject seo = null)
        {
            if (source == null)
            {
                source = dt.ExtendedProperties[templateFieldDataTable.shema_sourceinstance] as IDataRowSetter;
            }
            var dc = dt.Columns.Add(propertyName, typeof(string));

            if (seo == null)
            {
                seo = new settingsEntriesForObject(source);
            }
            if (!seo.spes.ContainsKey(propertyName))
            {
                dc.Caption = propertyName;
            }
            else
            {
                settingsMemberInfoEntry smi = seo.spes[propertyName];
                dc.Caption = smi.displayName;

                // smi.exportPropertyCollection(dc.ExtendedProperties);
            }

            return(dc);
        }
예제 #6
0
        /// <summary>
        /// Prepares the collection table shema
        /// </summary>
        /// <param name="__type">The type.</param>
        protected void prepare(Type __type, string __primaryKeyPropertyName, string __name, bool buildTheTable = true)
        {
            name = __name;
            type = __type;

            if (type.isCompatibileWith(typeof(IObjectTableEntry)))
            {
                IsInstanceLinkActive = true;
                instanceRegistry     = new ConcurrentDictionary <string, IObjectTableEntry>();
            }

            primaryKeyName = __primaryKeyPropertyName;
            settings       = new settingsEntriesForObject(type, false);

            if (imbSciStringExtensions.isNullOrEmptyString(primaryKeyName))
            {
                foreach (settingsPropertyEntry spe in settings.spes.Values)
                {
                    if (spe.isPrimaryKey)
                    {
                        primaryKeyName = spe.pi.Name;
                    }
                }
            }

            if (buildTheTable)
            {
                buildTable();
            }
        }
예제 #7
0
        /// <summary>
        /// Sets the additional information entries by data object properties, being of <c>propertyTypes</c> type
        /// </summary>
        /// <param name="dc">The dc.</param>
        /// <param name="data_name_refix">The data name refix.</param>
        /// <param name="data_value">The data value.</param>
        /// <param name="propertyTypes">The property types.</param>
        /// <returns></returns>
        public static DataTable SetAdditionalInfoEntries(this DataTable dc, String data_name_refix, Object data_value, params Type[] propertyTypes)
        {
            if (data_value == null)
            {
                return(dc);
            }
            if (data_name_refix.isNullOrEmpty())
            {
                data_name_refix = "data";
            }
            settingsEntriesForObject sEO = new settingsEntriesForObject(data_value, false, false);

            foreach (var spe in sEO.spes.Values)
            {
                if (propertyTypes.Contains(spe.type))
                {
                    if (spe.value != null)
                    {
                        dc.SetAdditionalInfoEntry(data_name_refix.add(spe.name, "_"), spe.value);
                    }
                }
                //if (containsQueries.Contains(propertyTypes, spe.type))
                //{

                //}
            }
            return(dc);
        }
예제 #8
0
        public void setObject(Object __editorTarget)
        {
            editorTarget = __editorTarget;
            settingSpecs = new settingsEntriesForObject(editorTarget, true);

            menu.Remove(propertyMenuItems);

            propertyMenuItems.Clear();
            if (settingSpecs != null)
            {
                foreach (var _spec in settingSpecs.spes)
                {
                    aceMenuItem specItem = new aceMenuItem(_spec.Value.displayName, "", _spec.Value.description, "",
                                                           _spec.Value);
                    specItem.group = aceMenuItemGroup.mainItems;
                    propertyMenuItems.Add(specItem);
                    menu.setItem(specItem);
                }
            }
            menu.selected = menu.getFirstSafe() as aceMenuItem;

            menu.menuTitle = settingSpecs.targetType.Name + " variables";
            pageManager    = new textPageManager <aceMenuItem>(10);

            pageManager.refresh(menu);
        }
        /// <summary>
        /// Builds the data table hor dictionary.
        /// </summary>
        /// <typeparam name="TKey">The type of the key.</typeparam>
        /// <typeparam name="T"></typeparam>
        /// <param name="itemKeys">The item keys.</param>
        /// <param name="columns">The columns.</param>
        /// <returns></returns>
        public static DataTable BuildDataTableHorDictionary <TKey, T>(this IDictionary <TKey, T> itemKeys, string valuePath, string KeyCaption, PropertyEntryColumn extraColumn, string[] columns)
        {
            object source = null;
            TKey   firstKey;

            foreach (var pair in itemKeys)
            {
                firstKey = pair.Key;
                source   = pair.Value.imbGetPropertySafe(valuePath);
                break;
            }

            var       seo = new settingsEntriesForObject(source);
            DataTable dt  = new DataTable(typeof(T).Name);

            DataColumn dcKey = dt.Columns.Add(KEYCOLUMN);

            dcKey.Caption = KeyCaption;

            source.BuildDataShema(columns, extraColumn, seo, dt);

            List <Enum>[] output = convertPEColumn(extraColumn);

            if (extraColumn != PropertyEntryColumn.none)
            {
                foreach (PropertyEntryColumn extra in output[0])
                {
                    dt.AddExtraRow(extra);
                }
            }

            int c = 0;

            foreach (var pair in itemKeys)
            {
                object it  = pair.Value.imbGetPropertySafe(valuePath);
                string key = pair.Key.toStringSafe();

                DataRow dr = dt.SetDataRow(it, extraColumn, seo);
                dr[dcKey] = key;
                c++;
            }

            if (extraColumn != PropertyEntryColumn.none)
            {
                foreach (PropertyEntryColumn extra in output[1])
                {
                    dt.AddExtraRow(extra);
                }
            }

            //dt.TableName = title;
            //dt.ExtendedProperties[templateFieldDataTable.data_tabledesc] = description;
            //dt.ExtendedProperties[templateFieldDataTable.data_tablename] = title;
            dt.ExtendedProperties[templateFieldDataTable.data_tablescount] = c;

            return(dt);
        }
        /// <summary>
        /// Sets or updates the preset using data annotations from <c>type</c>
        /// </summary>
        /// <param name="type">Type to read data annotation attributes from</param>
        /// <param name="skipExistingAnnotations">if set to <c>true</c>, it will not update already defined data annotation rule of a property.</param>
        public void SetFrom(Type type, Boolean skipExistingAnnotations = true)
        {
            name = type.Name;
            settingsEntriesForObject sEO = new settingsEntriesForObject(type, false);

            foreach (KeyValuePair <string, settingsPropertyEntryWithContext> pce in sEO.spes)
            {
                SetFrom(pce.Value, skipExistingAnnotations);
            }
            CategoryByPriority = sEO.CategoryByPriority;
            description        = description.add("Imported from data type [" + type.Name + "]", ". ");
        }
        /// <summary>
        /// Deploys the specified data object.
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        public void Deploy(Object dataObject)
        {
            DataObjectInfo = new settingsEntriesForObject(dataObject, false);
            DataObject     = dataObject;

            if (DataObject is INotifyPropertyChanged DataObjectPropertyChanged)
            {
                DataObjectPropertyChanged.PropertyChanged += DataObjectPropertyChanged_PropertyChanged;
            }

            Title       = DataObjectInfo.DisplayName;
            Description = DataObjectInfo.Description;
        }
        /// <summary>
        /// Builds the data table using reflection and selected columns. Supports formating instruction, expression and other advanced atributes
        /// </summary>
        /// <param name="items">The items.</param>
        /// <param name="title">The title.</param>
        /// <param name="description">The description.</param>
        /// <param name="columns">The columns.</param>
        /// <returns></returns>
        public static DataTable BuildDataTableHorizontal(this IEnumerable items, string title, string description, PropertyEntryColumn extraColumn, string[] columns)
        {
            object source = null;

            foreach (object it in items)
            {
                source = it;
                break;
            }
            if (source == null)
            {
                return(null);
            }

            var       seo = new settingsEntriesForObject(source);
            DataTable dt  = source.BuildDataShema(columns, extraColumn, seo);

            List <Enum>[] output = convertPEColumn(extraColumn);

            if (extraColumn != PropertyEntryColumn.none)
            {
                foreach (PropertyEntryColumn extra in output[0])
                {
                    dt.AddExtraRow(extra);
                }
            }

            int c = 0;

            foreach (object it in items)
            {
                dt.SetDataRow(it, extraColumn, seo);
                c++;
            }

            if (extraColumn != PropertyEntryColumn.none)
            {
                foreach (PropertyEntryColumn extra in output[1])
                {
                    dt.AddExtraRow(extra);
                }
            }

            dt.TableName = title;
            dt.ExtendedProperties[templateFieldDataTable.data_tabledesc]   = description;
            dt.ExtendedProperties[templateFieldDataTable.data_tablename]   = title;
            dt.ExtendedProperties[templateFieldDataTable.data_tablescount] = c;

            return(dt);
        }
        /// <summary>
        /// Gets the right column value
        /// </summary>
        /// <param name="column">The column.</param>
        /// <param name="pce">The pce.</param>
        /// <param name="c">Row count - required if <see cref="PropertyEntryColumn.autocount_idcolumn"/> is the <c>column</c>.</param>
        /// <param name="autocount_format">The autocount format.</param>
        /// <returns></returns>
        public static object getColumnValue(this PropertyEntry column, object instance, int c, string autocount_format)
        {
            settingsEntriesForObject sef = new settingsEntriesForObject(instance, false);

            object vl  = getColumnValue_Default;
            object key = column[PropertyEntryColumn.entry_key];

            if (key is PropertyEntryColumn)
            {
                PropertyEntryColumn pec = (PropertyEntryColumn)key;
                switch (pec)
                {
                case PropertyEntryColumn.entry_name:
                    vl = sef.spes[column.keyName].displayName;
                    break;

                case PropertyEntryColumn.entry_description:
                    vl = sef.spes[column.keyName].description;
                    break;

                case PropertyEntryColumn.autocount_idcolumn:

                    vl = c.ToString(autocount_format);
                    break;

                default:

                    //vl = column.getColumn(pec, [key]);
                    break;
                }
            }
            else
            {
                vl = instance.GetType().GetProperty(column.keyName).GetValue(instance, null);
                // vl = instance.GetPropertyValue(column.keyName);

                if (sef.spes[column.keyName].type == typeof(int) || sef.spes[column.keyName].type == typeof(double))
                {
                    vl = string.Format(sef.spes[column.keyName].format, vl);
                    //vl = String.Format(, )
                }
                else
                {
                }
            }
            return(vl);
        }
        public static DataRow SetDataRow(this DataTable dt, object source, PropertyEntryColumn extraColumn, settingsEntriesForObject seo = null)
        {
            if (seo == null)
            {
                seo = new settingsEntriesForObject(source);
            }

            DataRow dr = dt.NewRow();

            foreach (DataColumn col in dt.Columns)
            {
                if (columnsToSkip.Contains(col.ColumnName))
                {
                    continue;
                }
                object val = null; //  source.GetPropertyValue(col.ColumnName);
                throw new NotImplementedException();

                if (val is IFormattable)
                {
                    IFormattable valf = (IFormattable)val;
                    if (col.ExtendedProperties.ContainsKey(templateFieldDataTable.col_format))
                    {
                        string format = col.ExtendedProperties[templateFieldDataTable.col_format].toStringSafe();
                        if (col.AutoIncrement)
                        {
                        }
                        else
                        {
                            val = valf.ToString(format, null);
                        }
                    }
                }

                if (col.ExtendedProperties.ContainsKey(templateFieldDataTable.col_expression))
                {
                    col.Expression = col.ExtendedProperties[templateFieldDataTable.col_expression].toStringSafe();
                }

                dr[col] = val;
            }
            dt.Rows.Add(dr);
            return(dr);
        }
예제 #15
0
        public static void DeployPropertiesAndFormatting(this DirectedGraph graph, Node node, Object nodeSource,
                                                         Boolean setProperties = true,
                                                         Boolean useFormatting = true)
        {
            if (!setProperties && !useFormatting)
            {
                return;
            }

            settingsEntriesForObject SEO = nodeSource.GetType().GetSEO();

            if (useFormatting)
            {
                graph.DeployFormatting(node, nodeSource, SEO);
            }
            if (setProperties)
            {
                graph.DeployProperties(node, nodeSource, SEO);
            }
        }
        /// <summary>
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="doInherited">if set to <c>true</c> [do inherited].</param>
        /// <param name="filedName_prefix">The filed name prefix.</param>
        /// <param name="output">The output.</param>
        /// <param name="fieldsOrCategoriesToShow">The fields or categories to show.</param>
        /// <returns></returns>
        public static PropertyCollectionExtended buildPCE(this Object source, Boolean doInherited, PropertyCollectionExtended output = null, params String[] fieldsOrCategoriesToShow)
        {
            List <String> filter = fieldsOrCategoriesToShow.getFlatList <String>();

            if (output == null)
            {
                output = new PropertyCollectionExtended();
            }

            var spo = new settingsEntriesForObject(source);

            foreach (var s in spo.spes)
            {
                //  output.Add(s.Value.pe);
                output.Add(s.Key, s.Value.displayName, s.Value.name, s.Value.description, s.Value.unit, s.Value.letter);
            }

            // DataTable dt = source.buildDataTable("Properties", false, true, doInherited, null);

            return(output);
        }
예제 #17
0
        /// <summary>
        /// Deploys the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        protected void Deploy(Type type)
        {
            hostType = type;
            var hostTypeInfo = new settingsEntriesForObject(type, false);

            foreach (var spe in hostTypeInfo.spes)
            {
                if (IsTypeAcceptable(spe.Value.pi))
                {
                    metricProperties.Add(spe.Value.pi, new rangeFinderForProperty <T>(spe.Value.pi));
                }
                else if (spe.Value.pi.PropertyType == typeof(String))
                {
                    textProperties.Add(spe.Value.pi, spe.Value);
                    textPropertyValues.Add(spe.Value.pi, "");
                }
                else
                {
                }
            }
        }
예제 #18
0
        protected dataUnitMap(Type instanceType, Type unitType)
        {
            var props = instanceType.GetProperties(BindingFlags.Instance | BindingFlags.Public);

            typePropertyDictionary = new settingsEntriesForObject(instanceType, false, true);

            // fieldsByNeedle.Add(presObj.key, new List<string>());
            monitor = new dataUnitRowMonitoring();

            foreach (KeyValuePair <string, settingsPropertyEntryWithContext> pair in typePropertyDictionary.spes)
            {
                if (pair.Value.pi.isReadWrite())
                {
                    if (!pair.Value.groups.Any())
                    {
                        pair.Value.groups.Add(DEFGROUP);
                    }

                    foreach (string group in pair.Value.groups)
                    {
                        if (!fieldsByNeedle.ContainsKey(group))
                        {
                            fieldsByNeedle.Add(group, new List <string>());
                        }
                        fieldsByNeedle[group].Add(pair.Key);
                    }
                    columns.Add(pair.Value);
                    var monF = pair.Value.getMonitoringFunction(instanceType);
                    if (monF != null)
                    {
                        monitor.targets.Add(pair.Key, monF);
                    }
                }
            }

            columns.Sort((x, y) => x.priority.CompareTo(y.priority));
        }
        /// <summary>
        /// Generates property manual
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        /// <param name="output">The output.</param>
        public static void GetUserManual(this Object dataObject, ITextRender output, String directInfo = "", Boolean skipUnDescribed = true, Boolean showValue = true)
        {
            settingsEntriesForObject seo = new settingsEntriesForObject(dataObject, false, false);

            String heading = "";

            if (!seo.Category.isNullOrEmpty())
            {
                heading += seo.Category + ": ";
            }

            output.AppendHeading(heading + seo.DisplayName, 2);

            List <String> description = new List <string>();

            if (!seo.Description.isNullOrEmpty())
            {
                output.AppendSection(seo.Description, "Class: " + dataObject.GetType().Name, dataObject.GetType().Namespace, seo.additionalInfo);
            }

            if (!directInfo.isNullOrEmpty())
            {
                output.AppendComment(directInfo);
            }

            var list = seo.spes.Values.ToList().OrderBy(x => x.categoryName);

            foreach (settingsPropertyEntryWithContext spec in list)
            {
                if (spec.description.isNullOrEmpty() && skipUnDescribed)
                {
                }
                else
                {
                    output.AppendHeading(imbSciStringExtensions.add(spec.categoryName, spec.displayName, ": "), 3);
                    output.AppendPair("Property name: ", spec.pi.Name);
                    output.AppendPair("Type: ", spec.pi.PropertyType.Name);

                    if (!spec.description.isNullOrEmpty())
                    {
                        output.AppendParagraph(spec.description);
                    }

                    if (!spec.letter.isNullOrEmpty())
                    {
                        output.AppendPair("Annotation: ", spec.letter);
                    }
                    if (!spec.unit.isNullOrEmpty())
                    {
                        output.AppendPair("Unit: ", spec.unit);
                    }
                    if (spec.aggregation != null)
                    {
                        output.AppendPair("Aggregation: ", spec.aggregation.multiTableType.ToString());
                    }

                    if (showValue)
                    {
                        if (spec.value != null)
                        {
                            output.AppendPair("Value: ", spec.value.toStringSafe(spec.format));
                        }
                    }

                    if (spec.type.IsEnum)
                    {
                        output.AppendPair("Possible values: ", spec.type.GetEnumNames().toCsvInLine());
                    }
                    else if (spec.type == typeof(Int32))
                    {
                    }

                    if (!spec.info_helpTitle.isNullOrEmpty())
                    {
                        output.AppendLabel(spec.info_helpTitle);
                        output.AppendQuote(spec.info_helpTips);
                    }

                    if (!spec.info_link.isNullOrEmpty())
                    {
                        output.AppendLink(spec.info_link, "More", "More");
                    }

                    output.AppendHorizontalLine();
                }
            }

            if (!seo.info_helpTitle.isNullOrEmpty())
            {
                output.AppendLabel(seo.info_helpTitle);
                output.AppendQuote(seo.info_helpTips);
            }

            if (!seo.info_link.isNullOrEmpty())
            {
                output.AppendLink(seo.info_link, "More", "More");
            }
        }
        public static DataTable GetParallelAggregates <T>(this List <IEnumerable <T> > sources, string column_snap, string column_prefix, dataPointAggregationType column_sideAggregates, params string[] column_toInclude)
        {
            settingsEntriesForObject sEO        = new settingsEntriesForObject(typeof(T));
            settingsPropertyEntry    sPE_snap   = sEO.spes[column_snap];
            settingsPropertyEntry    sPE_prefix = sEO.spes[column_prefix];

            List <settingsPropertyEntry> sPE_toInclude = new List <settingsPropertyEntry>();

            foreach (string toInclude in column_toInclude)
            {
                sPE_toInclude.Add(sEO.spes[toInclude]);
            }

            List <dataPointAggregationType> side_aggregates = column_sideAggregates.getEnumListFromFlags <dataPointAggregationType>();

            Dictionary <dataPointAggregationType, settingsPropertyEntry> sPE_sideAggregates = new Dictionary <dataPointAggregationType, settingsPropertyEntry>();

            Dictionary <settingsPropertyEntry, dataPointAggregationType> sPE_sideAggregatesContra = new Dictionary <settingsPropertyEntry, dataPointAggregationType>();

            foreach (settingsPropertyEntry toInclude in sPE_toInclude)
            {
                foreach (dataPointAggregationType sideType in side_aggregates)
                {
                    settingsPropertyEntry sPE = new settingsPropertyEntry(toInclude.pi);
                    sPE.type = typeof(double);
                    sPE.name = sPE.name + "_" + sideType.ToString();
                    sPE_sideAggregates.Add(sideType, sPE);
                    sPE_sideAggregatesContra.Add(sPE, sideType);
                }
            }

            // <---------------------------- preparing data

            Dictionary <string, IEnumerable <T> > dataByPrefix = new Dictionary <string, IEnumerable <T> >();
            int c = 0;

            foreach (IEnumerable <T> s in sources)
            {
                T firstItem = s.FirstOrDefault <T>();
                if (firstItem != null)
                {
                    string prefix = firstItem.imbGetPropertySafe(sPE_prefix.pi).toStringSafe(c.ToString("D3"));
                    dataByPrefix.Add(prefix, s);
                }
                c++;
            }

            // <----- DataColumn Index

            aceDictionarySet <string, DataColumn> columnsByPrefix = new aceDictionarySet <string, DataColumn>();

            aceDictionarySet <string, DataColumn> columnsSideAggregationByPrefix = new aceDictionarySet <string, DataColumn>();

            // <------------------------- building Shema
            DataTable output = new DataTable();

            output.TableName = "ParallelAggregate_by_" + column_snap;

            DataColumn            col_recordID = output.Add("ID", "Row ordinal number", "ID", typeof(int), dataPointImportance.normal, "D3").SetUnit("#");
            settingsPropertyEntry sPE_recID    = col_recordID.GetSPE();

            DataColumn col_snap = output.Add(sPE_snap);

            aceDictionary2D <settingsPropertyEntry, dataPointAggregationType, DataColumn> columnsByAggregationType = new aceDictionary2D <settingsPropertyEntry, dataPointAggregationType, DataColumn>();
            aceDictionarySet <settingsPropertyEntry, DataColumn> columnsBySource = new aceDictionarySet <settingsPropertyEntry, DataColumn>();

            foreach (settingsPropertyEntry toInclude in sPE_toInclude)
            {
                foreach (var pair in dataByPrefix)
                {
                    DataColumn nColumn = output.Add(toInclude);
                    nColumn.ColumnName = pair.Key + "_" + nColumn.ColumnName;
                    nColumn.SetGroup(pair.Key);

                    columnsByPrefix.Add(pair.Key, nColumn);

                    columnsBySource.Add(toInclude, nColumn);
                }

                foreach (var pair2 in sPE_sideAggregatesContra)
                {
                    DataColumn nColumn2 = output.Add(toInclude);
                    nColumn2.SetGroup("Aggregate");

                    //                    columnsSideAggregationByPrefix.Add(pair.Key, nColumn);
                }
            }

            // <----------------------------------------------------------- collecting rows

            aceDictionary2D <string, settingsPropertyEntry, object> dataRowBySnapValue = new aceDictionary2D <string, settingsPropertyEntry, object>();

            int riMax = 0;

            foreach (string prefix in dataByPrefix.Keys)
            {
                IEnumerable <T> s  = dataByPrefix[prefix];
                int             ri = 0;
                foreach (T si in s)
                {
                    ri++;
                    string snapValue = si.imbGetPropertySafe(sPE_snap.pi).toStringSafe();

                    dataRowBySnapValue[snapValue, sPE_snap]  = snapValue;
                    dataRowBySnapValue[snapValue, sPE_recID] = ri;

                    foreach (settingsPropertyEntry toInclude in sPE_toInclude)
                    {
                        foreach (var pair in columnsByPrefix[prefix])
                        {
                            var spe = dataColumnRenderingSetup.GetSPE(pair);

                            dataRowBySnapValue[snapValue, spe] = si.imbGetPropertySafe(spe.pi);
                        }
                    }
                    riMax = Math.Max(ri, riMax);
                }
            }

            foreach (string prefix in dataByPrefix.Keys)
            {
            }

            //List<Double> data = new List<Double>();
            //foreach (var pair2 in columnsSideAggregationByPrefix[prefix])
            //{
            //    var spe2 = pair.GetSPE();

            //    dataRowBySnapValue[snapValue, spe2] = si.imbGetPropertySafe(spe2.pi);
            //}

            return(output);
        }
        public static Grid GetInputGrid(this settingsEntriesForObject objectInfo, String groupName = "")
        {
            var displayGrid = new Grid();



            var groupDict = objectInfo.GetMemberInfoGroupDictionary();

            if (groupName == "")
            {
            }
            else
            {
                if (groupDict.ContainsKey(groupName))
                {
                    groupDict = groupDict.GetSubsection(groupName);
                }
            }

            // building row definitions
            foreach (var group in groupDict.Values)
            {
                displayGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });                                                                                                  // for the group name
                foreach (var groupProps in group)
                {
                    displayGrid.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    });
                }
            }

            displayGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(10, GridUnitType.Absolute)
            });
            displayGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            displayGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(10, GridUnitType.Absolute)
            });

            Int32 right = displayGrid.ColumnDefinitions.Count - 1;

            Int32 row = 0;

            foreach (var group in groupDict.Values)
            {
                Label groupLabel = new Label();
                groupLabel.Text = group.GroupName;
                displayGrid.Children.Add(groupLabel, 0, right, row, row + 1);
                row++;

                foreach (var groupProps in group)
                {
                    Label letterLabel = new Label();
                    letterLabel.Text = groupProps.letter;
                    displayGrid.Children.Add(letterLabel, 0, row);


                    Entry valueEntry = new Entry();
                    valueEntry.Placeholder = groupProps.displayName;
                    valueEntry.Text        = objectInfo.spes[groupProps.name].value.ToString();
                    displayGrid.Children.Add(valueEntry, 1, row);

                    Label unitLabel = new Label();
                    unitLabel.Text = groupProps.unit;
                    displayGrid.Children.Add(unitLabel, 2, row);

                    row++;
                }
            }

            return(displayGrid);
        }
예제 #22
0
 public cacheSimpleBase(folderNode __directory, int __hoursLimit, string __subFolder) : base(__directory, __hoursLimit, __subFolder)
 {
     typeInfo = new settingsEntriesForObject(typeof(T));
 }
예제 #23
0
 public static void DeployFormatting(this DirectedGraph graph, Node node, Object nodeSource, settingsEntriesForObject SEO)
 {
     if (node.Label.isNullOrEmpty())
     {
         node.Label = SEO.DisplayName;
     }
 }
예제 #24
0
        public static void DeployProperties(this DirectedGraph graph, Node node, Object nodeSource, settingsEntriesForObject SEO)
        {
            foreach (KeyValuePair <string, settingsPropertyEntryWithContext> spe in SEO.spes)
            {
                settingsPropertyEntryWithContext sPEC = spe.Value;

                graph.PropertyDeclaration.RegisterProperty(spe.Value);
                node.Properties.Add(sPEC.pi.GetGUI(), sPEC.pi.GetValue(nodeSource, null).toStringSafe(), "");
            }
        }