protected override T GetKeyForItem(BenchmarkItemSetting <T> item) { if (item == null) { throw new ArgumentNullException(); } return(item.Item); }
/// <summary> /// Processes the IO. /// </summary> /// <param name="componentTemplateIODictionary">The io dictionary of either Inputs of Outputs of the component template.</param> /// <param name="settings">input or output settings for the composite component that is being defined</param> /// <param name="benchmarkMappingSettingsCollection">The benchmark setting collection .</param> private static void ProcessIO(IDictionary <string, IOItem> componentTemplateIODictionary, SortedDictionary <string, ItemSetting> settings, BenchmarkSettingCollection <IOItem> benchmarkMappingSettingsCollection) { MultiDictionary <string, ItemSetting> lookupByType = new MultiDictionary <string, ItemSetting>(); //first prepare lookup by type foreach (KeyValuePair <string, ItemSetting> pair in settings) { ItemSetting item = pair.Value; //as default don't include it item.Include = false; lookupByType.Add(item.Type, item); } foreach (string itemKey in componentTemplateIODictionary.Keys) { IOItem item = componentTemplateIODictionary[itemKey]; //check if there are any item settings with matching type IEnumerable <ItemSetting> matchingItemSettings; if (lookupByType.TryGetValue(item.IOItemDefinition.Type, out matchingItemSettings)) { ItemSettingCollection list = new ItemSettingCollection(matchingItemSettings); //add all to the candidate matching items - these are items that user can choose from var setting = new BenchmarkItemSetting <IOItem>(item, list); benchmarkMappingSettingsCollection.Add(setting); setting.SelectedSetting = setting.CandidateSettings[0]; } else { //add empty list - no matching items - benchmarking cannot be executed var setting = new BenchmarkItemSetting <IOItem>(item, new ItemSettingCollection()); benchmarkMappingSettingsCollection.Add(setting); } } }