Example #1
0
        private void AddFieldsToTable(TableTwo pTable, string[] pFieldNames, string[] pDataTypeNames)
        {
            D.assert(pFieldNames.Length == pDataTypeNames.Length, "field definitions does not match");

            for (int i = 0; i < pFieldNames.Length; i++)
            {
                Type   genericType  = typeof(TableField <>);
                string dataTypeName = pDataTypeNames[i];
                //Console.WriteLine(dataTypeName);
                Type[] typeArgs = null;

                // Check through all assemblies for the type arguemnts
                foreach (Assembly assm in AppDomain.CurrentDomain.GetAssemblies())
                {
                    typeArgs = new Type[] { assm.GetType(dataTypeName) };
                    if (typeArgs[0] != null)
                    {
                        break; //found type
                    }
                }

                D.isNull(typeArgs[0], dataTypeName + " was not found ");
                Type repositoryType = genericType.MakeGenericType(typeArgs);

                ITableField result = (ITableField)Activator.CreateInstance(repositoryType, pFieldNames[i]);
                pTable.AddField(result);
            }
        }
Example #2
0
        internal void AddField(ITableField pField)
        {
            pField.rowCount = capacity;
            _fields.Add(pField.name, pField);
#if DEBUG
            EnsureFieldEquality();
#endif
        }
Example #3
0
        /// <summary>
        /// Append all entries in all tables, source IDs will be discarded.
        /// </summary>
        public void AppendTables(RelayTwo pRelay)
        {
            RelayTwo additiveRelay = pRelay;

            // Cycle through all new tables in the loaded relay
            foreach (String tableName in additiveRelay.tables.Keys)
            {
                TableTwo fromTable = additiveRelay.tables[tableName];
                // If the table already exists, append the entries from the new table.
                if (tables.ContainsKey(tableName))
                {
                    TableTwo toTable = tables[tableName];
                    // Ensure that all fields exists in the old table.
                    foreach (ITableField f in fromTable.fields)
                    {
                        if (!toTable.fieldNames.Contains(f.name))
                        {
                            toTable.AddField(f.GetEmptyCopy());
                        }
                    }
                    foreach (TableRow fromRow in fromTable)
                    {
                        TableRow toRow = toTable.CreateRow();
                        foreach (ITableField fromField in fromTable.fields)
                        {
                            ITableField toField = toTable.GetField(fromField.name);
                            toField.SetValueFromString(toRow.row, fromField.GetValueAsString(fromRow.row));
                        }
                    }
                }
                else
                {
                    this.tables[fromTable.name] = fromTable;
                }
            }
        }