private static IOrderedEnumerable <Tank> Sort(IEnumerable <Tank> tanks) { var settings = GameClientExplorerSettings.Default; switch ((VehicleSortingRule)settings.SortTanksBy) { case VehicleSortingRule.Class: { Func <Tank, int> selector = t => TankClassComparer.GetClassSortIndex(t.ClassKey); if (settings.SortTanksDescending) { return(tanks.OrderByDescending(selector)); } else { return(tanks.OrderBy(selector)); } } case VehicleSortingRule.Name: { Func <Tank, string> selector = t => t.Name; if (settings.SortTanksDescending) { return(tanks.OrderByDescending(selector)); } else { return(tanks.OrderBy(selector)); } } case VehicleSortingRule.Tier: { Func <Tank, int> selector = t => t.Tier; if (settings.SortTanksDescending) { return(tanks.OrderByDescending(selector)); } else { return(tanks.OrderBy(selector)); } } default: throw new NotSupportedException(); } }
public TankVM(RepositoryVM repository, Tank tank) { this.Repository = repository; this.Model = tank; this.TankUnikey = new TankUnikey(repository.Model, tank); this.Name = tank.Name; this.ShortName = tank.ShortName; this.Tier = RomanNumberService.GetRomanNumber(tank.Tier); this.ClassSortIndex = TankClassComparer.GetClassSortIndex(tank.ClassKey); this.Nation = tank.NationKey; var gameClient = repository.Model as LocalGameClient; if (gameClient != null) { App.BeginInvokeBackground(() => this.SmallIcon = gameClient.PackageImages.GetTankSmallIcon(tank.IconKey)); this.NationIcon = gameClient.PackageImages.GetNationSmallIcon(tank.NationKey); this.ClassIcon = gameClient.PackageImages.GetClassSmallIcon(tank.ClassKey); } }