本文整理汇总了C#中ConcurrentDictionary.MaxBy方法的典型用法代码示例。如果您正苦于以下问题:C# ConcurrentDictionary.MaxBy方法的具体用法?C# ConcurrentDictionary.MaxBy怎么用?C# ConcurrentDictionary.MaxBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConcurrentDictionary
的用法示例。
在下文中一共展示了ConcurrentDictionary.MaxBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowModificationImportWindowDialog
public void ShowModificationImportWindowDialog(string modificationPath)
{
var rootNodeViewModel = modificationImportViewModelFactory.FromDirectory(modificationPath);
var solution = riotSolutionLoader.Load(@"V:\Riot Games\League of Legends\RADS", RiotProjectType.AirClient | RiotProjectType.GameClient);
var airResolver = new Resolver(solution.ProjectsByType[RiotProjectType.AirClient].ReleaseManifest.Root);
var gameResolver = new Resolver(solution.ProjectsByType[RiotProjectType.GameClient].ReleaseManifest.Root);
var fileNodes = rootNodeViewModel.EnumerateFileNodes().ToArray();
var importWindow = new ModificationImportWindow();
var modificationImportViewModel = new ModificationImportViewModel(this, importWindow, rootNodeViewModel);
modificationImportViewModel.ModificationFriendlyName = fileSystemProxy.GetDirectoryInfo(modificationPath).Name;
importWindow.DataContext = modificationImportViewModel;
new Thread(() => {
foreach (var fileNode in fileNodes) {
var path = fileNode.Path;
var airResolution = airResolver.Resolve(path);
if (airResolution.Any()) {
fileNode.ResolutionPath = airResolution.First().GetPath();
fileNode.ResolutionState = ResolutionState.ResolutionSuccessful;
} else {
var gameResolutions = gameResolver.Resolve(path);
if (gameResolutions.Any()) {
fileNode.ResolutionPath = gameResolutions.First().GetPath();
fileNode.ResolutionState = ResolutionState.ResolutionSuccessful;
} else {
fileNode.ResolutionState = ResolutionState.ResolutionFailed;
}
}
}
LeagueModificationCategory modificationType = LeagueModificationCategory.Other;
if (fileNodes.Any(node => node.ResolutionState == ResolutionState.ResolutionSuccessful)) {
var modificationTypeCounts = new ConcurrentDictionary<LeagueModificationCategory, int>();
foreach (var file in fileNodes) {
if (file.ResolutionState == ResolutionState.ResolutionSuccessful) {
if (file.ResolutionPath.IndexOf("DATA/Characters", StringComparison.OrdinalIgnoreCase) != -1 ||
file.ResolutionPath.IndexOf("assets/images/champions", StringComparison.OrdinalIgnoreCase) != -1) {
if (file.ResolutionPath.IndexOf("ward", StringComparison.OrdinalIgnoreCase) != -1) {
modificationTypeCounts.AddOrUpdate(LeagueModificationCategory.Ward, 1, (existing, count) => count + 1);
} else {
modificationTypeCounts.AddOrUpdate(LeagueModificationCategory.Champion, 1, (existing, count) => count + 1);
}
} else if (file.ResolutionPath.IndexOf("LEVELS") != -1) {
modificationTypeCounts.AddOrUpdate(LeagueModificationCategory.Map, 1, (existing, count) => count + 1);
} else if (file.ResolutionPath.IndexOf("Menu", StringComparison.OrdinalIgnoreCase) != -1) {
modificationTypeCounts.AddOrUpdate(LeagueModificationCategory.UserInterface, 1, (existing, count) => count + 1);
} else {
modificationTypeCounts.AddOrUpdate(LeagueModificationCategory.Other, 1, (existing, count) => count + 1);
}
}
}
var categorizationCounts = modificationTypeCounts.Sum(x => x.Value);
var highestCategorization = modificationTypeCounts.MaxBy(key => key.Value, Comparer<int>.Default);
if (highestCategorization.Value >= categorizationCounts * 2.0 / 3.0) {
modificationType = modificationTypeCounts.MaxBy(key => key.Value, Comparer<int>.Default).Key;
}
Console.WriteLine("Highest categorization: " + highestCategorization.Key.Name);
modificationTypeCounts.ForEach(x => Console.WriteLine(x.Key.Name + ": " + x.Value));
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() => {
modificationImportViewModel.ModificationCategorization = modificationType;
}));
}
}).Start();
importWindow.ShowDialog();
}