/// <summary> /// Refreshes existing results repository. /// <note>Sorts existing results by groups also.</note> /// </summary> public static void RefreshExistingResults() { existingResults.Clear(); List <ResearchResult> results = storage.LoadAllResearchInfo(); foreach (ResearchResult r in results) { existingResults.Add(r.ResearchID, r); } SortExistingResultsByGroups(); }
private void convert_Click(Object sender, EventArgs e) { convert.Enabled = false; StorageType sourceType = (StorageType)Enum.Parse(typeof(StorageType), sourceStorageTypeCmb.Text); string sourceStr = sourceResultTxt.Text; StorageType targetType = (StorageType)Enum.Parse(typeof(StorageType), targetStorageCmb.Text); string targetStr = targetResultTxt.Text; Type[] patametersType = { typeof(String) }; Object[] sinvokeParameters = { sourceStr }; StorageTypeInfo[] sinfo = (StorageTypeInfo[])sourceType.GetType().GetField(sourceType.ToString()).GetCustomAttributes(typeof(StorageTypeInfo), false); Type st = Type.GetType(sinfo[0].Implementation, true); AbstractResultStorage sourceStorage = (AbstractResultStorage)st.GetConstructor(patametersType).Invoke(sinvokeParameters); Object[] tinvokeParameters = { targetStr }; StorageTypeInfo[] tinfo = (StorageTypeInfo[])targetType.GetType().GetField(targetType.ToString()).GetCustomAttributes(typeof(StorageTypeInfo), false); Type tt = Type.GetType(tinfo[0].Implementation, true); AbstractResultStorage targetStorage = (AbstractResultStorage)tt.GetConstructor(patametersType).Invoke(tinvokeParameters); List <ResearchResult> allResearchInfo = sourceStorage.LoadAllResearchInfo(); ResearchResult temp; foreach (ResearchResult r in allResearchInfo) { temp = sourceStorage.Load(r.ResearchID); targetStorage.Save(temp); } MessageBox.Show("Successfully converted from " + sourceStorageTypeCmb.Text + " to " + targetStorageCmb.Text + "."); convert.Enabled = true; }