本文整理汇总了C#中MultiDictionary.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# MultiDictionary.TryGetValue方法的具体用法?C# MultiDictionary.TryGetValue怎么用?C# MultiDictionary.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiDictionary
的用法示例。
在下文中一共展示了MultiDictionary.TryGetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessIO
/// <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);
}
}
}