Removal of ToArray()

This commit is contained in:
Brett Hewitson 2021-12-16 00:21:23 +10:00
parent 9eb22da9e7
commit 9f5cf132f0
41 changed files with 184 additions and 189 deletions

View file

@ -17,15 +17,13 @@ namespace ServerManagerTool.Lib
public override void FromIniValues(IEnumerable<string> iniValues)
{
var items = iniValues?.Select(AggregateIniValue.FromINIValue<EngramAutoUnlock>).ToArray();
var items = iniValues?.Select(AggregateIniValue.FromINIValue<EngramAutoUnlock>);
Clear();
var itemsToAdd = items.Where(i => !this.Any(e => e.IsEquivalent(i))).ToArray();
AddRange(itemsToAdd);
AddRange(items.Where(i => !this.Any(e => e.IsEquivalent(i))));
var itemsToUpdate = items.Where(i => this.Any(e => e.IsEquivalent(i))).ToArray();
foreach (var item in itemsToUpdate)
foreach (var item in items.Where(i => this.Any(e => e.IsEquivalent(i))))
{
var e = this.FirstOrDefault(r => r.IsEquivalent(item));
e.LevelToAutoUnlock = item.LevelToAutoUnlock;

View file

@ -18,15 +18,13 @@ namespace ServerManagerTool.Lib
public override void FromIniValues(IEnumerable<string> iniValues)
{
var items = iniValues?.Select(AggregateIniValue.FromINIValue<EngramEntry>).ToArray();
var items = iniValues?.Select(AggregateIniValue.FromINIValue<EngramEntry>);
Clear();
var itemsToAdd = items.Where(i => !this.Any(e => e.IsEquivalent(i))).ToArray();
AddRange(itemsToAdd);
AddRange(items.Where(i => !this.Any(e => e.IsEquivalent(i))));
var itemsToUpdate = items.Where(i => this.Any(e => e.IsEquivalent(i))).ToArray();
foreach (var item in itemsToUpdate)
foreach (var item in items.Where(i => this.Any(e => e.IsEquivalent(i))))
{
var e = this.FirstOrDefault(r => r.IsEquivalent(item));
e.EngramLevelRequirement = item.EngramLevelRequirement;

View file

@ -61,7 +61,7 @@ namespace ServerManagerTool.Lib
int index = 0;
int xpTotal = 0;
int engramTotal = 0;
foreach (var existingLevel in this.OrderBy(l => l.XPRequired).ToArray())
foreach (var existingLevel in this.OrderBy(l => l.XPRequired))
{
xpTotal += existingLevel.XPRequired;
engramTotal += existingLevel.EngramPoints;

View file

@ -14,11 +14,9 @@ namespace ServerManagerTool.Lib
{
}
public string[] RenderToView()
public IEnumerable<string> RenderToView()
{
List<string> errors = new List<string>();
return errors.ToArray();
return new List<string>();
}
public void RenderToModel()

View file

@ -1,5 +1,4 @@
using ServerManagerTool.Common.Model;
using ServerManagerTool.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
@ -18,22 +17,20 @@ namespace ServerManagerTool.Lib
public override void FromIniValues(IEnumerable<string> iniValues)
{
var items = iniValues?.Select(AggregateIniValue.FromINIValue<ResourceClassMultiplier>).ToArray();
var items = iniValues?.Select(AggregateIniValue.FromINIValue<ResourceClassMultiplier>);
Clear();
if (this._resetFunc != null)
this.AddRange(this._resetFunc());
var itemsToAdd = items.Where(i => !this.Any(r => r.IsEquivalent(i))).ToArray();
AddRange(itemsToAdd);
AddRange(items.Where(i => !this.Any(r => r.IsEquivalent(i))));
var itemsToUpdate = items.Where(i => this.Any(r => r.IsEquivalent(i))).ToArray();
foreach (var item in itemsToUpdate)
foreach (var item in items.Where(i => this.Any(r => r.IsEquivalent(i))))
{
this.FirstOrDefault(r => r.IsEquivalent(item)).Multiplier = item.Multiplier;
}
IsEnabled = (items.Length > 0);
IsEnabled = (Count > 0);
Sort(AggregateIniValue.SortKeySelector);
}

View file

@ -14,7 +14,7 @@ namespace ServerManagerTool.Lib
{
}
public string[] RenderToView()
public IEnumerable<string> RenderToView()
{
List<string> errors = new List<string>();
@ -27,7 +27,7 @@ namespace ServerManagerTool.Lib
}
}
return errors.ToArray();
return errors;
}
public void RenderToModel()

View file

@ -17,7 +17,7 @@ namespace ServerManagerTool.Lib
{
}
public string[] RenderToView()
public IEnumerable<string> RenderToView()
{
List<string> errors = new List<string>();
@ -48,7 +48,7 @@ namespace ServerManagerTool.Lib
Update();
return errors.ToArray();
return errors;
}
public void RenderToModel()

View file

@ -1875,7 +1875,7 @@ namespace ServerManagerTool.Lib
comment.AppendLine($"PGM Server: {_profile.PGM_Enabled}");
comment.AppendLine($"Process: {ServerProcess}");
ZipUtils.ZipFiles(backupFile, files.ToArray(), comment.ToString(), false);
ZipUtils.ZipFiles(backupFile, files, comment.ToString(), false);
LogProfileMessage($"Backup file created - {backupFile}");
}
@ -2025,7 +2025,7 @@ namespace ServerManagerTool.Lib
comment.AppendLine($"PGM Server: {_profile.PGM_Enabled}");
comment.AppendLine($"Process: {ServerProcess}");
ZipUtils.ZipFiles(backupFile, files.ToArray(), comment.ToString(), false);
ZipUtils.ZipFiles(backupFile, files, comment.ToString(), false);
LogProfileMessage($"Backed up world files - {saveFolder}");
LogProfileMessage($"Backup file created - {backupFile}");
@ -2998,7 +2998,7 @@ namespace ServerManagerTool.Lib
if (ExitCode == EXITCODE_NORMALEXIT)
{
// get the profile associated with the branch
var profiles = _profiles.Keys.Where(p => p.EnableAutoUpdate && p.BranchName.Equals(branch.BranchName, StringComparison.OrdinalIgnoreCase)).ToArray();
var profiles = _profiles.Keys.Where(p => p.EnableAutoUpdate && p.BranchName.Equals(branch.BranchName, StringComparison.OrdinalIgnoreCase));
var profileExitCodes = new ConcurrentDictionary<ServerProfileSnapshot, int>();
if (Config.Default.AutoUpdate_ParallelUpdate)
@ -3249,7 +3249,7 @@ namespace ServerManagerTool.Lib
if (exitCode == EXITCODE_NORMALEXIT)
{
var branches = _profiles.Keys.Where(p => p.EnableAutoUpdate).Select(p => BranchSnapshot.Create(p)).Distinct(new BranchSnapshotComparer()).ToArray();
var branches = _profiles.Keys.Where(p => p.EnableAutoUpdate).Select(p => BranchSnapshot.Create(p)).Distinct(new BranchSnapshotComparer());
var exitCodes = new ConcurrentDictionary<BranchSnapshot, int>();
// update the server cache for each branch

View file

@ -223,7 +223,7 @@ namespace ServerManagerTool.Lib
token.ThrowIfCancellationRequested();
// remove any players that do not have a player file.
var droppedPlayers = _players.Values.Where(p => dataContainer.Players.FirstOrDefault(pd => pd.PlayerId.Equals(p.PlayerId, StringComparison.OrdinalIgnoreCase)) == null).ToArray();
var droppedPlayers = _players.Values.Where(p => dataContainer.Players.FirstOrDefault(pd => pd.PlayerId.Equals(p.PlayerId, StringComparison.OrdinalIgnoreCase)) == null);
foreach (var droppedPlayer in droppedPlayers)
{
_players.TryRemove(droppedPlayer.PlayerId, out PlayerInfo player);

View file

@ -3593,7 +3593,7 @@ namespace ServerManagerTool.Lib
}
}
private static Enum[] GetExclusions()
private static IEnumerable<Enum> GetExclusions()
{
var exclusions = new List<Enum>();
@ -3637,7 +3637,7 @@ namespace ServerManagerTool.Lib
exclusions.Add(ServerProfileCategory.SOTF);
}
return exclusions.ToArray();
return exclusions;
}
private LevelList GetLevelList(LevelProgression levelProgression)
@ -4022,7 +4022,7 @@ namespace ServerManagerTool.Lib
return profile;
}
public static ServerProfile LoadFromINIFiles(string file, ServerProfile profile, Enum[] exclusions = null)
public static ServerProfile LoadFromINIFiles(string file, ServerProfile profile, IEnumerable<Enum> exclusions = null)
{
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
return null;
@ -4394,7 +4394,7 @@ namespace ServerManagerTool.Lib
SaveINIFile(configDir);
}
public void SaveINIFile(string profileIniDir, Enum[] exclusions = null)
public void SaveINIFile(string profileIniDir, IEnumerable<Enum> exclusions = null)
{
if (exclusions == null)
exclusions = GetExclusions();
@ -4418,7 +4418,7 @@ namespace ServerManagerTool.Lib
filteredValues.AddRange(this.PlayerLevels.ToINIValuesForEngramPoints());
}
iniFile.WriteSection(IniFiles.Game, IniSections.Game_ShooterGameMode, filteredValues.ToArray());
iniFile.WriteSection(IniFiles.Game, IniSections.Game_ShooterGameMode, filteredValues);
}
public bool UpdateDirectoryPermissions()
@ -5860,7 +5860,7 @@ namespace ServerManagerTool.Lib
this.CustomEngineSettings.Clear();
foreach (var section in sourceProfile.CustomEngineSettings)
{
this.CustomEngineSettings.Add(section.SectionName, section.ToIniValues().ToArray());
this.CustomEngineSettings.Add(section.SectionName, section.ToIniValues());
}
}
@ -5869,7 +5869,7 @@ namespace ServerManagerTool.Lib
this.CustomGameSettings.Clear();
foreach (var section in sourceProfile.CustomGameSettings)
{
this.CustomGameSettings.Add(section.SectionName, section.ToIniValues().ToArray());
this.CustomGameSettings.Add(section.SectionName, section.ToIniValues());
}
}
@ -5878,7 +5878,7 @@ namespace ServerManagerTool.Lib
this.CustomGameUserSettings.Clear();
foreach (var section in sourceProfile.CustomGameUserSettings)
{
this.CustomGameUserSettings.Add(section.SectionName, section.ToIniValues().ToArray());
this.CustomGameUserSettings.Add(section.SectionName, section.ToIniValues());
}
}
@ -6530,7 +6530,7 @@ namespace ServerManagerTool.Lib
Directory.CreateDirectory(folder);
var file = Path.Combine(folder, Config.Default.ArkAdminFile);
File.WriteAllLines(file, this.ServerFilesAdmins.ToArray());
File.WriteAllLines(file, this.ServerFilesAdmins.ToEnumerable());
}
catch (Exception ex)
{
@ -6547,7 +6547,7 @@ namespace ServerManagerTool.Lib
Directory.CreateDirectory(folder);
var file = Path.Combine(folder, Config.Default.ArkExclusiveFile);
File.WriteAllLines(file, this.ServerFilesExclusive.ToArray());
File.WriteAllLines(file, this.ServerFilesExclusive.ToEnumerable());
}
catch (Exception ex)
{
@ -6564,7 +6564,7 @@ namespace ServerManagerTool.Lib
Directory.CreateDirectory(folder);
var file = Path.Combine(folder, Config.Default.ArkWhitelistFile);
File.WriteAllLines(file, this.ServerFilesWhitelisted.ToArray());
File.WriteAllLines(file, this.ServerFilesWhitelisted.ToEnumerable());
}
catch (Exception ex)
{

View file

@ -325,8 +325,8 @@ namespace ServerManagerTool.Lib
else if (command.command.Equals(RCON_COMMAND_GETCHAT, StringComparison.OrdinalIgnoreCase))
{
// TODO: Extract the player name from the chat
var lines = command.lines.Where(l => !String.IsNullOrEmpty(l) && l != NoResponseOutput).ToArray();
if (lines.Length == 0 && command.suppressCommand)
var lines = command.lines.Where(l => !String.IsNullOrEmpty(l) && l != NoResponseOutput);
if (!lines.Any() && command.suppressCommand)
{
command.suppressOutput = true;
}
@ -398,7 +398,7 @@ namespace ServerManagerTool.Lib
}
}
var droppedPlayers = this.players.Values.Where(p => onlinePlayers.FirstOrDefault(np => np.PlayerId.Equals(p.PlayerId, StringComparison.OrdinalIgnoreCase)) == null).ToArray();
var droppedPlayers = this.players.Values.Where(p => onlinePlayers.FirstOrDefault(np => np.PlayerId.Equals(p.PlayerId, StringComparison.OrdinalIgnoreCase)) == null);
foreach (var droppedPlayer in droppedPlayers)
{
if (droppedPlayer.IsOnline)
@ -604,7 +604,7 @@ namespace ServerManagerTool.Lib
token.ThrowIfCancellationRequested();
// remove any players that do not have a player file.
var droppedPlayers = this.players.Values.Where(p => dataContainer.Players.FirstOrDefault(pd => pd.PlayerId.Equals(p.PlayerId, StringComparison.OrdinalIgnoreCase)) == null).ToArray();
var droppedPlayers = this.players.Values.Where(p => dataContainer.Players.FirstOrDefault(pd => pd.PlayerId.Equals(p.PlayerId, StringComparison.OrdinalIgnoreCase)) == null);
foreach (var droppedPlayer in droppedPlayers)
{
players.TryRemove(droppedPlayer.PlayerId, out PlayerInfo player);

View file

@ -80,14 +80,13 @@ namespace ServerManagerTool.Lib.ViewModel
if (string.IsNullOrWhiteSpace(entry.EngramClassName))
continue;
var engramSettings = this.Where(vi => vi.EngramClassName == entry.EngramClassName).ToArray();
if (engramSettings == null || engramSettings.Length == 0)
if (!this.Any(vi => vi.EngramClassName == entry.EngramClassName))
{
var engram = GameData.GetEngramForClass(entry.EngramClassName);
this.Add(CreateEngramSetting(entry.EngramClassName, engram?.Mod ?? GameData.MOD_UNKNOWN, engram?.KnownEngram ?? false, engram?.IsTekgram ?? false));
}
engramSettings = this.Where(vi => vi.EngramClassName == entry.EngramClassName).ToArray();
var engramSettings = this.Where(vi => vi.EngramClassName == entry.EngramClassName);
foreach (var engramSetting in engramSettings)
{
engramSetting.EngramLevelRequirement = entry.EngramLevelRequirement;
@ -117,14 +116,13 @@ namespace ServerManagerTool.Lib.ViewModel
if (string.IsNullOrWhiteSpace(entry.EngramClassName))
continue;
var engramSettings = this.Where(vi => vi.EngramClassName == entry.EngramClassName).ToArray();
if (engramSettings == null || engramSettings.Length == 0)
if (!this.Any(vi => vi.EngramClassName == entry.EngramClassName))
{
var engram = GameData.GetEngramForClass(entry.EngramClassName);
this.Add(CreateEngramSetting(entry.EngramClassName, engram?.Mod ?? GameData.MOD_UNKNOWN, engram?.KnownEngram ?? false, engram?.IsTekgram ?? false));
}
engramSettings = this.Where(vi => vi.EngramClassName == entry.EngramClassName).ToArray();
var engramSettings = this.Where(vi => vi.EngramClassName == entry.EngramClassName);
foreach (var engramSetting in engramSettings)
{
engramSetting.EngramAutoUnlock = true;

View file

@ -990,7 +990,7 @@ namespace ServerManagerTool
var zipFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), this.Settings.ProfileID + ".zip");
if (File.Exists(zipFile)) File.Delete(zipFile);
ZipUtils.ZipFiles(zipFile, files.ToArray(), comment.ToString());
ZipUtils.ZipFiles(zipFile, files, comment.ToString());
foreach (var kvp in obfuscateFiles)
{
ZipUtils.ZipAFile(zipFile, kvp.Key, kvp.Value);
@ -1348,37 +1348,37 @@ namespace ServerManagerTool
foreach (var section in iniFile.Sections.Where(s => s.SectionName != null && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
var dinoSpawnWeightMultipliers = new AggregateIniValueList<DinoSpawn>(nameof(Server.Profile.DinoSpawnWeightMultipliers), null);
dinoSpawnWeightMultipliers.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{dinoSpawnWeightMultipliers.IniCollectionKey}=")));
dinoSpawnWeightMultipliers.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{dinoSpawnWeightMultipliers.IniCollectionKey}=")));
Server.Profile.DinoSpawnWeightMultipliers.AddRange(dinoSpawnWeightMultipliers);
Server.Profile.DinoSpawnWeightMultipliers.IsEnabled |= dinoSpawnWeightMultipliers.IsEnabled;
var preventDinoTameClassNames = new StringIniValueList(nameof(Server.Profile.PreventDinoTameClassNames), null);
preventDinoTameClassNames.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{preventDinoTameClassNames.IniCollectionKey}=")));
preventDinoTameClassNames.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{preventDinoTameClassNames.IniCollectionKey}=")));
Server.Profile.PreventDinoTameClassNames.AddRange(preventDinoTameClassNames);
Server.Profile.PreventDinoTameClassNames.IsEnabled |= preventDinoTameClassNames.IsEnabled;
var npcReplacements = new AggregateIniValueList<NPCReplacement>(nameof(Server.Profile.NPCReplacements), null);
npcReplacements.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{npcReplacements.IniCollectionKey}=")));
npcReplacements.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{npcReplacements.IniCollectionKey}=")));
Server.Profile.NPCReplacements.AddRange(npcReplacements);
Server.Profile.NPCReplacements.IsEnabled |= npcReplacements.IsEnabled;
var tamedDinoClassDamageMultipliers = new AggregateIniValueList<ClassMultiplier>(nameof(Server.Profile.TamedDinoClassDamageMultipliers), null);
tamedDinoClassDamageMultipliers.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{tamedDinoClassDamageMultipliers.IniCollectionKey}=")));
tamedDinoClassDamageMultipliers.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{tamedDinoClassDamageMultipliers.IniCollectionKey}=")));
Server.Profile.TamedDinoClassDamageMultipliers.AddRange(tamedDinoClassDamageMultipliers);
Server.Profile.TamedDinoClassDamageMultipliers.IsEnabled |= tamedDinoClassDamageMultipliers.IsEnabled;
var tamedDinoClassResistanceMultipliers = new AggregateIniValueList<ClassMultiplier>(nameof(Server.Profile.TamedDinoClassResistanceMultipliers), null);
tamedDinoClassResistanceMultipliers.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{tamedDinoClassResistanceMultipliers.IniCollectionKey}=")));
tamedDinoClassResistanceMultipliers.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{tamedDinoClassResistanceMultipliers.IniCollectionKey}=")));
Server.Profile.TamedDinoClassResistanceMultipliers.AddRange(tamedDinoClassResistanceMultipliers);
Server.Profile.TamedDinoClassResistanceMultipliers.IsEnabled |= tamedDinoClassResistanceMultipliers.IsEnabled;
var dinoClassDamageMultipliers = new AggregateIniValueList<ClassMultiplier>(nameof(Server.Profile.DinoClassDamageMultipliers), null);
dinoClassDamageMultipliers.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{dinoClassDamageMultipliers.IniCollectionKey}=")));
dinoClassDamageMultipliers.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{dinoClassDamageMultipliers.IniCollectionKey}=")));
Server.Profile.DinoClassDamageMultipliers.AddRange(dinoClassDamageMultipliers);
Server.Profile.DinoClassDamageMultipliers.IsEnabled |= dinoClassDamageMultipliers.IsEnabled;
var dinoClassResistanceMultipliers = new AggregateIniValueList<ClassMultiplier>(nameof(Server.Profile.DinoClassResistanceMultipliers), null);
dinoClassResistanceMultipliers.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{dinoClassResistanceMultipliers.IniCollectionKey}=")));
dinoClassResistanceMultipliers.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{dinoClassResistanceMultipliers.IniCollectionKey}=")));
Server.Profile.DinoClassResistanceMultipliers.AddRange(dinoClassResistanceMultipliers);
Server.Profile.DinoClassResistanceMultipliers.IsEnabled |= dinoClassResistanceMultipliers.IsEnabled;
}
@ -1458,7 +1458,7 @@ namespace ServerManagerTool
foreach (var section in iniFile.Sections.Where(s => s.SectionName != null && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
var harvestResourceItemAmountClassMultipliers = new AggregateIniValueList<ResourceClassMultiplier>(nameof(Server.Profile.HarvestResourceItemAmountClassMultipliers), null);
harvestResourceItemAmountClassMultipliers.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{harvestResourceItemAmountClassMultipliers.IniCollectionKey}=")));
harvestResourceItemAmountClassMultipliers.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{harvestResourceItemAmountClassMultipliers.IniCollectionKey}=")));
Server.Profile.HarvestResourceItemAmountClassMultipliers.AddRange(harvestResourceItemAmountClassMultipliers);
Server.Profile.HarvestResourceItemAmountClassMultipliers.IsEnabled |= harvestResourceItemAmountClassMultipliers.IsEnabled;
}
@ -1686,12 +1686,12 @@ namespace ServerManagerTool
foreach (var section in iniFile.Sections.Where(s => s.SectionName != null && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
var overrideNamedEngramEntries = new EngramEntryList(nameof(Server.Profile.OverrideNamedEngramEntries));
overrideNamedEngramEntries.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{overrideNamedEngramEntries.IniCollectionKey}=")));
overrideNamedEngramEntries.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{overrideNamedEngramEntries.IniCollectionKey}=")));
Server.Profile.OverrideNamedEngramEntries.AddRange(overrideNamedEngramEntries);
Server.Profile.OverrideNamedEngramEntries.IsEnabled |= overrideNamedEngramEntries.IsEnabled;
var engramEntryAutoUnlocks = new EngramAutoUnlockList(nameof(Server.Profile.EngramEntryAutoUnlocks));
engramEntryAutoUnlocks.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{engramEntryAutoUnlocks.IniCollectionKey}=")));
engramEntryAutoUnlocks.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{engramEntryAutoUnlocks.IniCollectionKey}=")));
Server.Profile.EngramEntryAutoUnlocks.AddRange(engramEntryAutoUnlocks);
Server.Profile.EngramEntryAutoUnlocks.IsEnabled |= engramEntryAutoUnlocks.IsEnabled;
}
@ -1790,7 +1790,7 @@ namespace ServerManagerTool
foreach (var section in iniFile.Sections.Where(s => s.SectionName != null && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
var configOverrideItemCraftingCosts = new AggregateIniValueList<CraftingOverride>(nameof(Server.Profile.ConfigOverrideItemCraftingCosts), null);
configOverrideItemCraftingCosts.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{configOverrideItemCraftingCosts.IniCollectionKey}=")));
configOverrideItemCraftingCosts.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{configOverrideItemCraftingCosts.IniCollectionKey}=")));
Server.Profile.ConfigOverrideItemCraftingCosts.AddRange(configOverrideItemCraftingCosts);
Server.Profile.ConfigOverrideItemCraftingCosts.IsEnabled |= configOverrideItemCraftingCosts.IsEnabled;
}
@ -1898,7 +1898,7 @@ namespace ServerManagerTool
// cycle through the sections, adding them to the custom section list. Will bypass any sections that are named as per the ARK default sections.
foreach (var section in iniFile.Sections.Where(s => !string.IsNullOrWhiteSpace(s.SectionName) && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
Settings.CustomGameUserSettings.Add(section.SectionName, section.KeysToStringArray(), false);
Settings.CustomGameUserSettings.Add(section.SectionName, section.KeysToStringEnumerable(), false);
}
MessageBox.Show(_globalizer.GetResourceString("ServerSettings_LoadCustomConfig_Label"), _globalizer.GetResourceString("ServerSettings_LoadCustomConfig_Title"), MessageBoxButton.OK, MessageBoxImage.Information);
@ -1957,7 +1957,7 @@ namespace ServerManagerTool
// cycle through the sections, adding them to the custom section list. Will bypass any sections that are named as per the ARK default sections.
foreach (var section in iniFile.Sections.Where(s => !string.IsNullOrWhiteSpace(s.SectionName) && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
Settings.CustomGameUserSettings.Add(section.SectionName, section.KeysToStringArray(), false);
Settings.CustomGameUserSettings.Add(section.SectionName, section.KeysToStringEnumerable(), false);
}
}
@ -1980,7 +1980,7 @@ namespace ServerManagerTool
var configIniFile = Path.Combine(ServerProfile.GetProfileServerConfigDir(Settings), Config.Default.ServerGameUserSettingsConfigFile);
// load only this section, using the full exclusion list
var tempServerProfile = ServerProfile.LoadFromINIFiles(configIniFile, null, exclusions.ToArray());
var tempServerProfile = ServerProfile.LoadFromINIFiles(configIniFile, null, exclusions);
// perform a profile sync
Settings.SyncSettings(ServerProfileCategory.CustomGameUserSettings, tempServerProfile);
}
@ -2059,7 +2059,7 @@ namespace ServerManagerTool
// cycle through the sections, adding them to the custom section list. Will bypass any sections that are named as per the ARK default sections.
foreach (var section in iniFile.Sections.Where(s => !string.IsNullOrWhiteSpace(s.SectionName) && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
Settings.CustomGameSettings.Add(section.SectionName, section.KeysToStringArray(), false);
Settings.CustomGameSettings.Add(section.SectionName, section.KeysToStringEnumerable(), false);
}
MessageBox.Show(_globalizer.GetResourceString("ServerSettings_LoadCustomConfig_Label"), _globalizer.GetResourceString("ServerSettings_LoadCustomConfig_Title"), MessageBoxButton.OK, MessageBoxImage.Information);
@ -2118,7 +2118,7 @@ namespace ServerManagerTool
// cycle through the sections, adding them to the custom section list. Will bypass any sections that are named as per the ARK default sections.
foreach (var section in iniFile.Sections.Where(s => !string.IsNullOrWhiteSpace(s.SectionName) && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
Settings.CustomGameSettings.Add(section.SectionName, section.KeysToStringArray(), false);
Settings.CustomGameSettings.Add(section.SectionName, section.KeysToStringEnumerable(), false);
}
}
@ -2141,7 +2141,7 @@ namespace ServerManagerTool
var configIniFile = Path.Combine(ServerProfile.GetProfileServerConfigDir(Settings), Config.Default.ServerGameUserSettingsConfigFile);
// load only this section, using the full exclusion list
var tempServerProfile = ServerProfile.LoadFromINIFiles(configIniFile, null, exclusions.ToArray());
var tempServerProfile = ServerProfile.LoadFromINIFiles(configIniFile, null, exclusions);
// perform a profile sync
Settings.SyncSettings(ServerProfileCategory.CustomGameSettings, tempServerProfile);
}
@ -2220,7 +2220,7 @@ namespace ServerManagerTool
// cycle through the sections, adding them to the custom section list. Will bypass any sections that are named as per the ARK default sections.
foreach (var section in iniFile.Sections.Where(s => !string.IsNullOrWhiteSpace(s.SectionName) && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
Settings.CustomEngineSettings.Add(section.SectionName, section.KeysToStringArray(), false);
Settings.CustomEngineSettings.Add(section.SectionName, section.KeysToStringEnumerable(), false);
}
MessageBox.Show(_globalizer.GetResourceString("ServerSettings_LoadCustomConfig_Label"), _globalizer.GetResourceString("ServerSettings_LoadCustomConfig_Title"), MessageBoxButton.OK, MessageBoxImage.Information);
@ -2279,7 +2279,7 @@ namespace ServerManagerTool
// cycle through the sections, adding them to the custom section list. Will bypass any sections that are named as per the ARK default sections.
foreach (var section in iniFile.Sections.Where(s => !string.IsNullOrWhiteSpace(s.SectionName) && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
Settings.CustomEngineSettings.Add(section.SectionName, section.KeysToStringArray(), false);
Settings.CustomEngineSettings.Add(section.SectionName, section.KeysToStringEnumerable(), false);
}
}
@ -2302,7 +2302,7 @@ namespace ServerManagerTool
var configIniFile = Path.Combine(ServerProfile.GetProfileServerConfigDir(Settings), Config.Default.ServerGameUserSettingsConfigFile);
// load only this section, using the full exclusion list
var tempServerProfile = ServerProfile.LoadFromINIFiles(configIniFile, null, exclusions.ToArray());
var tempServerProfile = ServerProfile.LoadFromINIFiles(configIniFile, null, exclusions);
// perform a profile sync
Settings.SyncSettings(ServerProfileCategory.CustomEngineSettings, tempServerProfile);
}
@ -2919,17 +2919,17 @@ namespace ServerManagerTool
foreach (var section in iniFile.Sections.Where(s => s.SectionName != null && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
var configAddNPCSpawnEntriesContainer = new NPCSpawnContainerList<NPCSpawnContainer>(nameof(Server.Profile.ConfigAddNPCSpawnEntriesContainer), NPCSpawnContainerType.Add);
configAddNPCSpawnEntriesContainer.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{configAddNPCSpawnEntriesContainer.IniCollectionKey}=")));
configAddNPCSpawnEntriesContainer.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{configAddNPCSpawnEntriesContainer.IniCollectionKey}=")));
Server.Profile.ConfigAddNPCSpawnEntriesContainer.AddRange(configAddNPCSpawnEntriesContainer);
Server.Profile.ConfigAddNPCSpawnEntriesContainer.IsEnabled |= configAddNPCSpawnEntriesContainer.IsEnabled;
var configSubtractNPCSpawnEntriesContainer = new NPCSpawnContainerList<NPCSpawnContainer>(nameof(Server.Profile.ConfigSubtractNPCSpawnEntriesContainer), NPCSpawnContainerType.Subtract);
configSubtractNPCSpawnEntriesContainer.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{configSubtractNPCSpawnEntriesContainer.IniCollectionKey}=")));
configSubtractNPCSpawnEntriesContainer.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{configSubtractNPCSpawnEntriesContainer.IniCollectionKey}=")));
Server.Profile.ConfigSubtractNPCSpawnEntriesContainer.AddRange(configSubtractNPCSpawnEntriesContainer);
Server.Profile.ConfigSubtractNPCSpawnEntriesContainer.IsEnabled |= configSubtractNPCSpawnEntriesContainer.IsEnabled;
var configOverrideNPCSpawnEntriesContainer = new NPCSpawnContainerList<NPCSpawnContainer>(nameof(Server.Profile.ConfigOverrideNPCSpawnEntriesContainer), NPCSpawnContainerType.Override);
configOverrideNPCSpawnEntriesContainer.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{configOverrideNPCSpawnEntriesContainer.IniCollectionKey}=")));
configOverrideNPCSpawnEntriesContainer.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{configOverrideNPCSpawnEntriesContainer.IniCollectionKey}=")));
Server.Profile.ConfigOverrideNPCSpawnEntriesContainer.AddRange(configOverrideNPCSpawnEntriesContainer);
Server.Profile.ConfigOverrideNPCSpawnEntriesContainer.IsEnabled |= configOverrideNPCSpawnEntriesContainer.IsEnabled;
}
@ -3123,7 +3123,7 @@ namespace ServerManagerTool
foreach (var section in iniFile.Sections.Where(s => s.SectionName != null && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
var configOverrideSupplyCrateItems = new SupplyCrateOverrideList(nameof(Server.Profile.ConfigOverrideSupplyCrateItems));
configOverrideSupplyCrateItems.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{configOverrideSupplyCrateItems.IniCollectionKey}=")));
configOverrideSupplyCrateItems.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{configOverrideSupplyCrateItems.IniCollectionKey}=")));
Server.Profile.ConfigOverrideSupplyCrateItems.AddRange(configOverrideSupplyCrateItems);
Server.Profile.ConfigOverrideSupplyCrateItems.IsEnabled |= configOverrideSupplyCrateItems.IsEnabled;
}
@ -3133,7 +3133,7 @@ namespace ServerManagerTool
RefreshBaseSupplyCrateList();
RefreshBasePrimalItemList();
if (errors.Length > 0)
if (errors.Any())
{
var error = $"The following errors have been found:\r\n\r\n{string.Join("\r\n", errors)}";
@ -3265,7 +3265,7 @@ namespace ServerManagerTool
foreach (var section in iniFile.Sections.Where(s => s.SectionName != null && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
var configOverrideItemMaxQuantity = new AggregateIniValueList<StackSizeOverride>(nameof(Server.Profile.ConfigOverrideItemMaxQuantity), null);
configOverrideItemMaxQuantity.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{configOverrideItemMaxQuantity.IniCollectionKey}=")));
configOverrideItemMaxQuantity.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{configOverrideItemMaxQuantity.IniCollectionKey}=")));
Server.Profile.ConfigOverrideItemMaxQuantity.AddRange(configOverrideItemMaxQuantity);
Server.Profile.ConfigOverrideItemMaxQuantity.IsEnabled |= configOverrideItemMaxQuantity.IsEnabled;
}
@ -3274,7 +3274,7 @@ namespace ServerManagerTool
RefreshBasePrimalItemList();
if (errors.Length > 0)
if (errors.Any())
{
var error = $"The following errors have been found:\r\n\r\n{string.Join("\r\n", errors)}";
@ -3365,7 +3365,7 @@ namespace ServerManagerTool
foreach (var section in iniFile.Sections.Where(s => s.SectionName != null && !SystemIniFile.IniSectionNames.ContainsValue(s.SectionName)))
{
var preventTransferForClassNames = new AggregateIniValueList<PreventTransferOverride>(nameof(Server.Profile.PreventTransferForClassNames), null);
preventTransferForClassNames.FromIniValues(section.KeysToStringArray().Where(s => s.StartsWith($"{preventTransferForClassNames.IniCollectionKey}=")));
preventTransferForClassNames.FromIniValues(section.KeysToStringEnumerable().Where(s => s.StartsWith($"{preventTransferForClassNames.IniCollectionKey}=")));
Server.Profile.PreventTransferForClassNames.AddRange(preventTransferForClassNames);
Server.Profile.PreventTransferForClassNames.IsEnabled |= preventTransferForClassNames.IsEnabled;
}
@ -3374,7 +3374,7 @@ namespace ServerManagerTool
RefreshBaseDinoList();
if (errors.Length > 0)
if (errors.Any())
{
var error = $"The following errors have been found:\r\n\r\n{string.Join("\r\n", errors)}";