private static void initializeConfig() { if (DataSetManager.Manager.getData(DataSets.Config, DataSetManager.GENERIC_TABLE_NAME) != null) { return; } Dictionary <string, string> values = new Dictionary <string, string>(); GeneralPreferences gp = new GeneralPreferences(); Dictionary <string, object> defaultValues = gp.GetValues(); //getControlValues(gp.Controls); Dictionary <string, Type> columns = new Dictionary <string, Type>(); foreach (KeyValuePair <string, object> kv in defaultValues) { columns.Add(kv.Key, kv.Value.GetType()); } DataSetManager.Manager.addTable(DataSets.Config, DataSetManager.GENERIC_TABLE_NAME, columns); DataSetManager.Manager.addValuesToEnd(DataSets.Config, DataSetManager.GENERIC_TABLE_NAME, defaultValues); columns = new Dictionary <string, Type>(); columns.Add(DataSetManager.SELECTED_MODULES_NAME_COLUMN_TAG, typeof(string)); DataSetManager.Manager.addTable(DataSets.Config, DataSetManager.SELECTED_MODULES_TABLE_NAME, columns, DataSetManager.SELECTED_MODULES_NAME_COLUMN_TAG); defaultValues = new Dictionary <string, object>(); defaultValues.Add(DataSetManager.SELECTED_MODULES_NAME_COLUMN_TAG, "GeneralInfo"); DataSetManager.Manager.addValuesToEnd(DataSets.Config, DataSetManager.SELECTED_MODULES_TABLE_NAME, defaultValues); DataSetManager.Manager.saveDataSet(DataSets.Config); }
public static Dictionary <string, object> getPreferenceData(string tag) { Dictionary <string, object> values = new Dictionary <string, object>(); if (tag == "General") { IEnumerator iterator = DataSetManager.Manager.getData(DataSets.Config, DataSetManager.GENERIC_TABLE_NAME); GeneralPreferences gp = new GeneralPreferences(); Dictionary <string, object> dataValues = gp.GetValues(); if (iterator.MoveNext()) { DataRow dr = ((DataRow)iterator.Current); foreach (KeyValuePair <string, object> kv in dataValues) { values[kv.Key] = dr[kv.Key]; } } else { foreach (KeyValuePair <string, object> kv in dataValues) { values[kv.Key] = kv.Value; } } } else { Dictionary <string, Type> modules = getModules(); Type[] types = new Type[0]; object[] parameters = new object[0]; IModule moduleObject = (modules[tag]).GetConstructor(types).Invoke(parameters) as IModule; if (moduleObject.preferencesAvailable()) // Previous Data Never Stored { IEnumerator iterator = DataSetManager.Manager.getData(DataSets.Config, tag); if (iterator == null || !iterator.MoveNext()) // No Table or Empty Table { PreferenceControl preferenceControl = moduleObject.getPreferenceControl(); Dictionary <string, object> mappings = preferenceControl.GetValues(); Dictionary <string, Type> columns = new Dictionary <string, Type>(); foreach (KeyValuePair <string, object> mapping in mappings) { values.Add(mapping.Key, mapping.Value); columns.Add(mapping.Key, mapping.Value.GetType()); } if (iterator == null) { DataSetManager.Manager.addTable(DataSets.Config, tag, columns); } } else// Should only have 1 data element { DataRow dr = iterator.Current as DataRow; foreach (DataColumn column in dr.Table.Columns) { values.Add(column.ColumnName, dr[column]); } } } } return(values); }