mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Removal of ToArray()
This commit is contained in:
parent
9eb22da9e7
commit
9f5cf132f0
41 changed files with 184 additions and 189 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)}";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
|
|
@ -18,29 +19,35 @@ namespace ArkData
|
|||
/// <returns>The async task context containing the resulting container.</returns>
|
||||
public static async Task<DataContainer> CreateAsync(string playerFileFolder, string tribeFileFolder)
|
||||
{
|
||||
var playerFiles = new string[0];
|
||||
var tribeFiles = new string[0];
|
||||
IEnumerable<string> playerFiles = null;
|
||||
IEnumerable<string> tribeFiles = null;
|
||||
|
||||
if (Directory.Exists(playerFileFolder))
|
||||
{
|
||||
playerFiles = Directory.GetFiles(playerFileFolder).Where(f => Path.GetFileNameWithoutExtension(f).StartsWith(DataFileDetails.PlayerFilePrefix)
|
||||
&& Path.GetFileNameWithoutExtension(f).EndsWith(DataFileDetails.PlayerFileSuffix)
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.PlayerFileExtension)).ToArray();
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.PlayerFileExtension));
|
||||
}
|
||||
if (Directory.Exists(tribeFileFolder))
|
||||
{
|
||||
tribeFiles = Directory.GetFiles(tribeFileFolder).Where(f => Path.GetFileNameWithoutExtension(f).StartsWith(DataFileDetails.TribeFilePrefix)
|
||||
&& Path.GetFileNameWithoutExtension(f).EndsWith(DataFileDetails.TribeFileSuffix)
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.TribeFileExtension)).ToArray();
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.TribeFileExtension));
|
||||
}
|
||||
|
||||
var container = new DataContainer();
|
||||
|
||||
foreach (var file in playerFiles)
|
||||
container.Players.Add(await Parser.ParsePlayerAsync(file));
|
||||
if (playerFiles != null)
|
||||
{
|
||||
foreach (var file in playerFiles)
|
||||
container.Players.Add(await Parser.ParsePlayerAsync(file));
|
||||
}
|
||||
|
||||
foreach (var file in tribeFiles)
|
||||
container.Tribes.Add(await Parser.ParseTribeAsync(file));
|
||||
if (tribeFiles != null)
|
||||
{
|
||||
foreach (var file in tribeFiles)
|
||||
container.Tribes.Add(await Parser.ParseTribeAsync(file));
|
||||
}
|
||||
|
||||
container.LinkPlayerTribe();
|
||||
|
||||
|
|
@ -58,14 +65,14 @@ namespace ArkData
|
|||
// need to make multiple calls of 100 steam id's.
|
||||
var lastSteamUpdateUtc = DateTime.UtcNow;
|
||||
var startIndex = 0;
|
||||
var playerSteamIds = Players.Where(p => p.LastPlatformUpdateUtc.AddMinutes(steamUpdateInterval) < DateTime.UtcNow).Select(p => p.PlayerId).ToArray();
|
||||
var playerSteamIds = Players.Where(p => p.LastPlatformUpdateUtc.AddMinutes(steamUpdateInterval) < DateTime.UtcNow).Select(p => p.PlayerId);
|
||||
|
||||
while (true)
|
||||
{
|
||||
// check if the start index has exceeded the Players list count.
|
||||
if (startIndex >= playerSteamIds.Length) break;
|
||||
if (startIndex >= playerSteamIds.Count()) break;
|
||||
// get the number of steam ids to read.
|
||||
int steamIdsCount = System.Math.Min(MAX_STEAM_IDS, playerSteamIds.Length - startIndex);
|
||||
int steamIdsCount = Math.Min(MAX_STEAM_IDS, playerSteamIds.Count() - startIndex);
|
||||
// get a comma delimited list of the steam ids to process
|
||||
var builder = string.Join(",", playerSteamIds, startIndex, steamIdsCount);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
|
|
@ -16,29 +17,35 @@ namespace ArkData
|
|||
/// </summary>
|
||||
public static DataContainer Create(string playerFileFolder, string tribeFileFolder)
|
||||
{
|
||||
var playerFiles = new string[0];
|
||||
var tribeFiles = new string[0];
|
||||
IEnumerable<string> playerFiles = null;
|
||||
IEnumerable<string> tribeFiles = null;
|
||||
|
||||
if (Directory.Exists(playerFileFolder))
|
||||
{
|
||||
playerFiles = Directory.GetFiles(playerFileFolder).Where(f => Path.GetFileNameWithoutExtension(f).StartsWith(DataFileDetails.PlayerFilePrefix)
|
||||
&& Path.GetFileNameWithoutExtension(f).EndsWith(DataFileDetails.PlayerFileSuffix)
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.PlayerFileExtension)).ToArray();
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.PlayerFileExtension));
|
||||
}
|
||||
if (Directory.Exists(tribeFileFolder))
|
||||
{
|
||||
tribeFiles = Directory.GetFiles(tribeFileFolder).Where(f => Path.GetFileNameWithoutExtension(f).StartsWith(DataFileDetails.TribeFilePrefix)
|
||||
&& Path.GetFileNameWithoutExtension(f).EndsWith(DataFileDetails.TribeFileSuffix)
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.TribeFileExtension)).ToArray();
|
||||
&& Path.GetExtension(f).Equals(DataFileDetails.TribeFileExtension));
|
||||
}
|
||||
|
||||
var container = new DataContainer();
|
||||
|
||||
foreach (var file in playerFiles)
|
||||
container.Players.Add(Parser.ParsePlayer(file));
|
||||
if (playerFiles != null)
|
||||
{
|
||||
foreach (var file in playerFiles)
|
||||
container.Players.Add(Parser.ParsePlayer(file));
|
||||
}
|
||||
|
||||
foreach (var file in tribeFiles)
|
||||
container.Tribes.Add(Parser.ParseTribe(file));
|
||||
if (tribeFiles != null)
|
||||
{
|
||||
foreach (var file in tribeFiles)
|
||||
container.Tribes.Add(Parser.ParseTribe(file));
|
||||
}
|
||||
|
||||
container.LinkPlayerTribe();
|
||||
|
||||
|
|
@ -56,14 +63,14 @@ namespace ArkData
|
|||
// need to make multiple calls of 100 steam id's.
|
||||
var lastSteamUpdateUtc = DateTime.UtcNow;
|
||||
var startIndex = 0;
|
||||
var playerSteamIds = Players.Where(p => p.LastPlatformUpdateUtc.AddMinutes(steamUpdateInterval) < DateTime.UtcNow).Select(p => p.PlayerId).ToArray();
|
||||
var playerSteamIds = Players.Where(p => p.LastPlatformUpdateUtc.AddMinutes(steamUpdateInterval) < DateTime.UtcNow).Select(p => p.PlayerId);
|
||||
|
||||
while (true)
|
||||
{
|
||||
// check if the start index has exceeded the Players list count.
|
||||
if (startIndex >= playerSteamIds.Length) break;
|
||||
if (startIndex >= playerSteamIds.Count()) break;
|
||||
// get the number of steam ids to read.
|
||||
int steamIdsCount = System.Math.Min(MAX_STEAM_IDS, playerSteamIds.Length - startIndex);
|
||||
int steamIdsCount = Math.Min(MAX_STEAM_IDS, playerSteamIds.Count() - startIndex);
|
||||
// get a comma delimited list of the steam ids to process
|
||||
var builder = string.Join(",", playerSteamIds, startIndex, steamIdsCount);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace ArkData
|
|||
return -1;
|
||||
}
|
||||
|
||||
public static int[] Locate(this byte[] self, byte[] candidate)
|
||||
public static IEnumerable<int> Locate(this byte[] self, byte[] candidate)
|
||||
{
|
||||
if (IsEmptyLocate(self, candidate, 0))
|
||||
return Empty;
|
||||
|
|
@ -29,7 +29,7 @@ namespace ArkData
|
|||
list.Add(position);
|
||||
|
||||
if (list.Count != 0)
|
||||
return list.ToArray();
|
||||
return list;
|
||||
|
||||
return Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1790,7 +1790,7 @@ namespace ServerManagerTool.Lib
|
|||
comment.AppendLine($"Profile Name: {_profile.ProfileName}");
|
||||
comment.AppendLine($"Process: {ServerProcess}");
|
||||
|
||||
ZipUtils.ZipFiles(backupFile, files.ToArray(), comment.ToString(), false);
|
||||
ZipUtils.ZipFiles(backupFile, files, comment.ToString(), false);
|
||||
|
||||
LogProfileMessage($"Backup file created - {backupFile}");
|
||||
}
|
||||
|
|
@ -1910,7 +1910,7 @@ namespace ServerManagerTool.Lib
|
|||
|
||||
ZipUtils.ZipAFile(backupFile, worldFileName, worldBackupFile, comment.ToString());
|
||||
if (files.Count > 0)
|
||||
ZipUtils.UpdateFiles(backupFile, files.ToArray(), null, false, "");
|
||||
ZipUtils.UpdateFiles(backupFile, files, null, false, "");
|
||||
|
||||
LogProfileMessage($"Backed up world files - {saveFolder}");
|
||||
LogProfileMessage($"Backup file created - {backupFile}");
|
||||
|
|
@ -2851,7 +2851,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)
|
||||
|
|
@ -3102,7 +3102,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
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ namespace ServerManagerTool.Lib
|
|||
return;
|
||||
|
||||
// remove any players that do not have a player record.
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -792,11 +792,9 @@ namespace ServerManagerTool.Lib
|
|||
}
|
||||
}
|
||||
|
||||
private static Enum[] GetExclusions()
|
||||
private static IEnumerable<Enum> GetExclusions()
|
||||
{
|
||||
var exclusions = new List<Enum>();
|
||||
|
||||
return exclusions.ToArray();
|
||||
return new List<Enum>();
|
||||
}
|
||||
|
||||
public string GetLauncherFile() => Path.Combine(GetProfileServerConfigDir(), Config.Default.LauncherFile);
|
||||
|
|
@ -885,7 +883,7 @@ namespace ServerManagerTool.Lib
|
|||
return profile;
|
||||
}
|
||||
|
||||
public static ServerProfile LoadFromConfigFiles(string file, ServerProfile profile, Enum[] exclusions = null)
|
||||
public static ServerProfile LoadFromConfigFiles(string file, ServerProfile profile, IEnumerable<Enum> exclusions = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
|
||||
return null;
|
||||
|
|
@ -1108,7 +1106,7 @@ namespace ServerManagerTool.Lib
|
|||
SaveConfigFile(serverConfigDir);
|
||||
}
|
||||
|
||||
public void SaveConfigFile(string configDir, Enum[] exclusions = null)
|
||||
public void SaveConfigFile(string configDir, IEnumerable<Enum> exclusions = null)
|
||||
{
|
||||
if (exclusions == null)
|
||||
exclusions = GetExclusions();
|
||||
|
|
@ -1656,7 +1654,7 @@ namespace ServerManagerTool.Lib
|
|||
Directory.CreateDirectory(folder);
|
||||
|
||||
var file = Path.Combine(folder, Config.Default.ServerBlacklistFile);
|
||||
File.WriteAllLines(file, this.ServerFilesBlacklisted.ToArray());
|
||||
File.WriteAllLines(file, this.ServerFilesBlacklisted.ToEnumerable());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -1673,7 +1671,7 @@ namespace ServerManagerTool.Lib
|
|||
Directory.CreateDirectory(folder);
|
||||
|
||||
var file = Path.Combine(folder, Config.Default.ServerWhitelistFile);
|
||||
File.WriteAllLines(file, this.ServerFilesWhitelisted.ToArray());
|
||||
File.WriteAllLines(file, this.ServerFilesWhitelisted.ToEnumerable());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ namespace ServerManagerTool.Lib
|
|||
return new List<string>();
|
||||
|
||||
// remove any players that do not have a player record.
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -720,7 +720,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);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace ServerManagerTool.Utils
|
|||
Directory.CreateDirectory(modRootFolder);
|
||||
|
||||
// get the a list of the mod file into include in the mod file
|
||||
var modFileItems = modIdList.Select(m => $"{m}.pak").ToArray();
|
||||
var modFileItems = modIdList.Select(m => $"{m}.pak");
|
||||
// create the mod file.
|
||||
File.WriteAllLines(modListFile, modFileItems);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,14 +50,7 @@ namespace QueryMaster
|
|||
//consecutive rcon command replies start with an empty packet
|
||||
if (BitConverter.ToInt32(recvData[i], 4) == (int)PacketId.Empty)
|
||||
continue;
|
||||
//if (recvData[i].Length - BitConverter.ToInt32(recvData[i], 0) == 4)
|
||||
//{
|
||||
str.Append(RconUtil.ProcessPacket(recvData[i]).Body);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// str.Append(RconUtil.ProcessPacket(recvData[i]).Body + Util.BytesToString(recvData[++i].Take(recvData[i].Length - 2).ToArray()));
|
||||
//}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace QueryMaster
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
namespace ServerManagerTool.Common.Interfaces
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ServerManagerTool.Common.Interfaces
|
||||
{
|
||||
public interface IIniSectionCollection
|
||||
{
|
||||
IIniValuesCollection[] Sections { get; }
|
||||
|
||||
void Add(string sectionName, string[] values);
|
||||
void Add(string sectionName, IEnumerable<string> values);
|
||||
|
||||
void Update();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace ServerManagerTool.Common.Lib
|
|||
{
|
||||
JsonProperty property = base.CreateProperty(member, memberSerialization);
|
||||
|
||||
var customAttributes = member.CustomAttributes?.ToArray() ?? new CustomAttributeData[0];
|
||||
var customAttributes = member.CustomAttributes ?? new CustomAttributeData[0];
|
||||
if (customAttributes.Any(a => a.AttributeType == typeof(System.Configuration.UserScopedSettingAttribute)))
|
||||
{
|
||||
property.ShouldSerialize = instance => { return property.PropertyType.IsValueType || property.PropertyType == typeof(string); };
|
||||
|
|
|
|||
|
|
@ -173,13 +173,13 @@ namespace ServerManagerTool.Common.Model
|
|||
|
||||
if (property.GetValue(this) is IIniValuesCollection collection)
|
||||
{
|
||||
var values = SplitCollectionValues(kvPropertyValue, DELIMITER);
|
||||
values = values.Where(v => !string.IsNullOrWhiteSpace(v)).ToArray();
|
||||
var values = SplitCollectionValues(kvPropertyValue, DELIMITER)
|
||||
.Where(v => !string.IsNullOrWhiteSpace(v));
|
||||
|
||||
if (attr?.ListValueWithinBrackets ?? false)
|
||||
{
|
||||
values = values.Select(v => v.Substring(1)).ToArray();
|
||||
values = values.Select(v => v.Substring(0, v.Length - 1)).ToArray();
|
||||
values = values.Select(v => v.Substring(1));
|
||||
values = values.Select(v => v.Substring(0, v.Length - 1));
|
||||
}
|
||||
collection.FromIniValues(values);
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ namespace ServerManagerTool.Common.Model
|
|||
return result.ToString();
|
||||
}
|
||||
|
||||
protected string[] SplitCollectionValues(string valueString, char delimiter)
|
||||
protected IEnumerable<string> SplitCollectionValues(string valueString, char delimiter)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(valueString))
|
||||
return new string[0];
|
||||
|
|
@ -306,7 +306,7 @@ namespace ServerManagerTool.Common.Model
|
|||
|
||||
result.Add(tempString.Substring(startIndex));
|
||||
|
||||
return result.ToArray();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Update(AggregateIniValue other)
|
||||
|
|
|
|||
|
|
@ -59,17 +59,16 @@ namespace ServerManagerTool.Common.Model
|
|||
|
||||
public virtual void FromIniValues(IEnumerable<string> iniValues)
|
||||
{
|
||||
var items = iniValues?.Select(AggregateIniValue.FromINIValue<T>).ToArray();
|
||||
var items = iniValues?.Select(AggregateIniValue.FromINIValue<T>);
|
||||
|
||||
Clear();
|
||||
AddRange(items);
|
||||
IsEnabled = (Count != 0);
|
||||
IsEnabled = (Count > 0);
|
||||
|
||||
// Add any default values which were missing
|
||||
if (_resetFunc != null)
|
||||
{
|
||||
var defaultItemsToAdd = _resetFunc().Where(r => !this.Any(v => v.IsEquivalent(r))).ToArray();
|
||||
AddRange(defaultItemsToAdd);
|
||||
AddRange(_resetFunc().Where(r => !this.Any(v => v.IsEquivalent(r))));
|
||||
}
|
||||
|
||||
Sort(AggregateIniValue.SortKeySelector);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using ServerManagerTool.Common.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ServerManagerTool.Common.Model
|
||||
|
|
@ -14,12 +15,12 @@ namespace ServerManagerTool.Common.Model
|
|||
}
|
||||
}
|
||||
|
||||
public void Add(string sectionName, string[] values)
|
||||
public void Add(string sectionName, IEnumerable<string> values)
|
||||
{
|
||||
Add(sectionName, values, true);
|
||||
}
|
||||
|
||||
public void Add(string sectionName, string[] values, bool clearExisting)
|
||||
public void Add(string sectionName, IEnumerable<string> values, bool clearExisting)
|
||||
{
|
||||
var section = this.Items.FirstOrDefault(s => s.SectionName.Equals(sectionName, StringComparison.OrdinalIgnoreCase) && !s.IsDeleted);
|
||||
if (section == null)
|
||||
|
|
|
|||
|
|
@ -98,8 +98,7 @@ namespace ServerManagerTool.Common.Model
|
|||
// Add any default values which were missing
|
||||
if (this.ResetFunc != null)
|
||||
{
|
||||
var defaultItemsToAdd = this.ResetFunc().Where(r => !this.Any(v => this.EquivalencyFunc(v, r))).ToArray();
|
||||
this.AddRange(defaultItemsToAdd);
|
||||
this.AddRange(this.ResetFunc().Where(r => !this.Any(v => this.EquivalencyFunc(v, r))));
|
||||
this.Sort(this.SortKeySelectorFunc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
|
@ -68,16 +69,15 @@ namespace ServerManagerTool.Common.Model
|
|||
|
||||
public void Remove(string steamId)
|
||||
{
|
||||
var items = this.Where(i => i.PlayerId.Equals(steamId, System.StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
foreach (var item in items)
|
||||
foreach (var item in this.Where(i => i.PlayerId.Equals(steamId, System.StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
this.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public string[] ToArray()
|
||||
public IEnumerable<string> ToEnumerable()
|
||||
{
|
||||
return this.Select(i => i.PlayerId).ToArray();
|
||||
return this.Select(i => i.PlayerId);
|
||||
}
|
||||
|
||||
public string ToDelimitedString(string delimiter)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace ServerManagerTool.Common.Model
|
|||
var tableValue = value as VdfTable;
|
||||
if (tableValue != null && tableValue.Count > 0)
|
||||
{
|
||||
var betaKeyItems = tableValue.Where(v => v.Name.Equals("betakey", StringComparison.OrdinalIgnoreCase)).ToArray();
|
||||
var betaKeyItems = tableValue.Where(v => v.Name.Equals("betakey", StringComparison.OrdinalIgnoreCase));
|
||||
foreach (var item in betaKeyItems)
|
||||
{
|
||||
tableValue.Remove(item);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
get;
|
||||
}
|
||||
|
||||
public void Deserialize(object obj, Enum[] exclusions)
|
||||
public void Deserialize(object obj, IEnumerable<Enum> exclusions)
|
||||
{
|
||||
var iniFiles = new Dictionary<string, IniFile>();
|
||||
var fields = obj.GetType()
|
||||
|
|
@ -168,7 +168,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
}
|
||||
}
|
||||
|
||||
public void Serialize(object obj, Enum[] exclusions)
|
||||
public void Serialize(object obj, IEnumerable<Enum> exclusions)
|
||||
{
|
||||
var iniFiles = new Dictionary<string, IniFile>();
|
||||
var fields = obj.GetType()
|
||||
|
|
@ -205,7 +205,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
|
||||
if (section.IsEnabled)
|
||||
{
|
||||
WriteSection(iniFiles, attr.File, section.IniCollectionKey, section.ToIniValues().ToArray());
|
||||
WriteSection(iniFiles, attr.File, section.IniCollectionKey, section.ToIniValues());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -228,8 +228,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
{
|
||||
var section = ReadSection(iniFiles, attr.File, attr.Section);
|
||||
var filteredSection = section
|
||||
.Where(s => !s.StartsWith(collection.IniCollectionKey + (collection.IsArray ? "[" : "=")))
|
||||
.ToArray();
|
||||
.Where(s => !s.StartsWith(collection.IniCollectionKey + (collection.IsArray ? "[" : "=")));
|
||||
WriteSection(iniFiles, attr.File, attr.Section, filteredSection);
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +313,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
result = result.Concat(collection.ToIniValues());
|
||||
}
|
||||
|
||||
WriteSection(iniFiles, attr.File, attr.Section, result?.ToArray());
|
||||
WriteSection(iniFiles, attr.File, attr.Section, result);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -381,29 +380,29 @@ namespace ServerManagerTool.Common.Serialization
|
|||
SaveFiles(iniFiles);
|
||||
}
|
||||
|
||||
public string[] ReadSection(Enum iniFile, Enum section)
|
||||
public IEnumerable<string> ReadSection(Enum iniFile, Enum section)
|
||||
{
|
||||
return ReadSection(iniFile, SectionNames[section]);
|
||||
}
|
||||
|
||||
public string[] ReadSection(Enum iniFile, string sectionName)
|
||||
public IEnumerable<string> ReadSection(Enum iniFile, string sectionName)
|
||||
{
|
||||
var file = Path.Combine(this.BasePath, FileNames[iniFile]);
|
||||
return IniFileUtils.ReadSection(file, sectionName);
|
||||
}
|
||||
|
||||
public void WriteSection(Enum iniFile, Enum section, string[] values)
|
||||
public void WriteSection(Enum iniFile, Enum section, IEnumerable<string> values)
|
||||
{
|
||||
WriteSection(iniFile, SectionNames[section], values);
|
||||
}
|
||||
|
||||
public void WriteSection(Enum iniFile, string sectionName, string[] values)
|
||||
public void WriteSection(Enum iniFile, string sectionName, IEnumerable<string> values)
|
||||
{
|
||||
var file = Path.Combine(this.BasePath, FileNames[iniFile]);
|
||||
IniFileUtils.WriteSection(file, sectionName, values);
|
||||
}
|
||||
|
||||
private string[] ReadCustomSectionNames(Dictionary<string, IniFile> iniFiles, Enum iniFile)
|
||||
private IEnumerable<string> ReadCustomSectionNames(Dictionary<string, IniFile> iniFiles, Enum iniFile)
|
||||
{
|
||||
if (!iniFiles.ContainsKey(FileNames[iniFile]))
|
||||
{
|
||||
|
|
@ -415,15 +414,15 @@ namespace ServerManagerTool.Common.Serialization
|
|||
}
|
||||
}
|
||||
|
||||
return iniFiles[FileNames[iniFile]].Sections.Select(s => s.SectionName).Where(s => !SectionNames.ContainsValue(s)).ToArray();
|
||||
return iniFiles[FileNames[iniFile]].Sections.Select(s => s.SectionName).Where(s => !SectionNames.ContainsValue(s));
|
||||
}
|
||||
|
||||
private string[] ReadSection(Dictionary<string, IniFile> iniFiles, Enum iniFile, Enum section)
|
||||
private IEnumerable<string> ReadSection(Dictionary<string, IniFile> iniFiles, Enum iniFile, Enum section)
|
||||
{
|
||||
return ReadSection(iniFiles, iniFile, SectionNames[section]);
|
||||
}
|
||||
|
||||
private string[] ReadSection(Dictionary<string, IniFile> iniFiles, Enum iniFile, string sectionName)
|
||||
private IEnumerable<string> ReadSection(Dictionary<string, IniFile> iniFiles, Enum iniFile, string sectionName)
|
||||
{
|
||||
if (!iniFiles.ContainsKey(FileNames[iniFile]))
|
||||
{
|
||||
|
|
@ -435,7 +434,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
}
|
||||
}
|
||||
|
||||
return iniFiles[FileNames[iniFile]].GetSection(sectionName)?.KeysToStringArray() ?? new string[0];
|
||||
return iniFiles[FileNames[iniFile]].GetSection(sectionName)?.KeysToStringEnumerable() ?? new string[0];
|
||||
}
|
||||
|
||||
private string ReadValue(Dictionary<string, IniFile> iniFiles, Enum iniFile, Enum section, string keyName)
|
||||
|
|
@ -453,12 +452,12 @@ namespace ServerManagerTool.Common.Serialization
|
|||
return iniFiles[FileNames[iniFile]].GetKey(SectionNames[section], keyName)?.KeyValue ?? string.Empty;
|
||||
}
|
||||
|
||||
private void WriteSection(Dictionary<string, IniFile> iniFiles, Enum iniFile, Enum section, string[] values)
|
||||
private void WriteSection(Dictionary<string, IniFile> iniFiles, Enum iniFile, Enum section, IEnumerable<string> values)
|
||||
{
|
||||
WriteSection(iniFiles, iniFile, SectionNames[section], values);
|
||||
}
|
||||
|
||||
private void WriteSection(Dictionary<string, IniFile> iniFiles, Enum iniFile, string sectionName, string[] values)
|
||||
private void WriteSection(Dictionary<string, IniFile> iniFiles, Enum iniFile, string sectionName, IEnumerable<string> values)
|
||||
{
|
||||
if (!iniFiles.ContainsKey(FileNames[iniFile]))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
Sections.Remove(section);
|
||||
}
|
||||
|
||||
public bool WriteSection(string sectionName, string[] keysValuePairs)
|
||||
public bool WriteSection(string sectionName, IEnumerable<string> keysValuePairs)
|
||||
{
|
||||
if (sectionName == null)
|
||||
return false;
|
||||
|
|
@ -186,7 +186,7 @@ namespace ServerManagerTool.Common.Serialization
|
|||
{
|
||||
result.AppendLine($"[{section.SectionName}]");
|
||||
|
||||
foreach (var keyString in section.KeysToStringArray())
|
||||
foreach (var keyString in section.KeysToStringEnumerable())
|
||||
{
|
||||
result.AppendLine(keyString);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ namespace ServerManagerTool.Common.Serialization
|
|||
return Keys?.FirstOrDefault(s => s.KeyName.Equals(keyName, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public string[] KeysToStringArray()
|
||||
public IEnumerable<string> KeysToStringEnumerable()
|
||||
{
|
||||
return Keys.Select(k => k.ToString()).ToArray();
|
||||
return Keys.Select(k => k.ToString());
|
||||
}
|
||||
|
||||
public void RemoveKey(string keyName)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using ServerManagerTool.Common.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
|
@ -13,13 +14,13 @@ namespace ServerManagerTool.Common.Utils
|
|||
/// <param name="file">The name of the initialization file.</param>
|
||||
/// <param name="sectionName">The name of the section in the initialization file.</param>
|
||||
/// <returns>A string array containing the key name and value pairs associated with the named section.</returns>
|
||||
public static string[] ReadSection(string file, string sectionName)
|
||||
public static IEnumerable<string> ReadSection(string file, string sectionName)
|
||||
{
|
||||
if (sectionName == null)
|
||||
return new string[0];
|
||||
|
||||
var iniFile = ReadFromFile(file);
|
||||
return iniFile?.GetSection(sectionName)?.KeysToStringArray() ?? new string[0];
|
||||
return iniFile?.GetSection(sectionName)?.KeysToStringEnumerable() ?? new string[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -46,7 +47,7 @@ namespace ServerManagerTool.Common.Utils
|
|||
/// <param name="sectionName">The name of the section in which data is written.</param>
|
||||
/// <param name="keysValuePairs">An array of key names and associated values that are to be written to the named section.</param>
|
||||
/// <returns>True if the function succeeds; otherwise False.</returns>
|
||||
public static bool WriteSection(string file, string sectionName, string[] keysValuePairs)
|
||||
public static bool WriteSection(string file, string sectionName, IEnumerable<string> keysValuePairs)
|
||||
{
|
||||
if (sectionName == null)
|
||||
return false;
|
||||
|
|
@ -165,7 +166,7 @@ namespace ServerManagerTool.Common.Utils
|
|||
{
|
||||
writer.WriteLine($"[{section.SectionName}]");
|
||||
|
||||
foreach (var keyString in section.KeysToStringArray())
|
||||
foreach (var keyString in section.KeysToStringEnumerable())
|
||||
{
|
||||
writer.WriteLine(keyString);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ namespace ServerManagerTool.Common.Utils
|
|||
}
|
||||
}
|
||||
|
||||
public static BigInteger[] GetProcessorAffinityList()
|
||||
public static IEnumerable<BigInteger> GetProcessorAffinityList()
|
||||
{
|
||||
var processorCount = ProcessorCount;
|
||||
var results = new List<BigInteger>(processorCount + 1);
|
||||
|
|
@ -295,7 +295,7 @@ namespace ServerManagerTool.Common.Utils
|
|||
{
|
||||
results.Add((BigInteger)Math.Pow(2, index));
|
||||
}
|
||||
return results.ToArray();
|
||||
return results;
|
||||
}
|
||||
|
||||
public static string[] GetProcessPriorityList()
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace ServerManagerTool.Common.Utils
|
|||
|
||||
try
|
||||
{
|
||||
var filesToDelete = new DirectoryInfo(backupPath).GetFiles($"{settingsFileName}_*{settingsFileExt}").Where(f => f.LastWriteTimeUtc.AddDays(7) < DateTime.UtcNow).ToArray();
|
||||
var filesToDelete = new DirectoryInfo(backupPath).GetFiles($"{settingsFileName}_*{settingsFileExt}").Where(f => f.LastWriteTimeUtc.AddDays(7) < DateTime.UtcNow);
|
||||
foreach (var fileToDelete in filesToDelete)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Ionic.Zip;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
|
|
@ -68,11 +69,11 @@ namespace ServerManagerTool.Common.Utils
|
|||
}
|
||||
}
|
||||
|
||||
public static void UpdateFiles(string zipFile, string[] filesToZip, string comment = "", bool preserveDirHierarchy = true, string directoryPathInArchive = "")
|
||||
public static void UpdateFiles(string zipFile, IEnumerable<string> filesToZip, string comment = "", bool preserveDirHierarchy = true, string directoryPathInArchive = "")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(zipFile))
|
||||
throw new ArgumentNullException(nameof(zipFile));
|
||||
if (filesToZip == null || filesToZip.Length == 0)
|
||||
if (!filesToZip.Any())
|
||||
return;
|
||||
|
||||
if (!File.Exists(zipFile))
|
||||
|
|
@ -160,11 +161,11 @@ namespace ServerManagerTool.Common.Utils
|
|||
}
|
||||
}
|
||||
|
||||
public static void ZipFiles(string zipFile, string[] filesToZip, string comment = "", bool preserveDirHierarchy = true, string directoryPathInArchive = "")
|
||||
public static void ZipFiles(string zipFile, IEnumerable<string> filesToZip, string comment = "", bool preserveDirHierarchy = true, string directoryPathInArchive = "")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(zipFile))
|
||||
throw new ArgumentNullException(nameof(zipFile));
|
||||
if (filesToZip == null || filesToZip.Length == 0)
|
||||
if (!filesToZip.Any())
|
||||
throw new ArgumentNullException(nameof(filesToZip));
|
||||
|
||||
using (var zip = new ZipFile(zipFile))
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ namespace ServerManagerTool.Updater
|
|||
var processes = ProcessUtils.GetProcesses(process.ProcessName, executablePath);
|
||||
|
||||
// check if there is more than one instance of the application running
|
||||
if (processes.Length != 1)
|
||||
if (processes.Count() != 1)
|
||||
throw new Exception("The application to be updated has more than one instance running.");
|
||||
|
||||
// get the command line of the process
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
|
@ -83,7 +84,7 @@ namespace ServerManagerTool.Updater
|
|||
return Process.GetProcessById(processId);
|
||||
}
|
||||
|
||||
public static Process[] GetProcesses(string processName, string executablePath)
|
||||
public static IEnumerable<Process> GetProcesses(string processName, string executablePath)
|
||||
{
|
||||
var runningProcesses = Process.GetProcessesByName(processName).ToList();
|
||||
|
||||
|
|
@ -95,7 +96,7 @@ namespace ServerManagerTool.Updater
|
|||
runningProcesses.RemoveAt(i);
|
||||
}
|
||||
|
||||
return runningProcesses.ToArray();
|
||||
return runningProcesses;
|
||||
}
|
||||
|
||||
public static bool IsAlreadyRunning()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue