small code refactoring

This commit is contained in:
Schedel Pascal
2024-06-19 08:10:16 +02:00
parent 20770bed31
commit c9216ac79b
93 changed files with 2753 additions and 5835 deletions

View File

@@ -1,31 +1,25 @@
using Newtonsoft.Json.Linq;
using Pilz.Updating.Administration.Discord;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pilz.Updating.Administration
namespace Pilz.Updating.Administration;
public class UpdateProject
{
public class UpdateProject
{
public UpdateServerConfig UpdateServerConfig { get; } = new UpdateServerConfig();
public DiscordBotConfig DiscordBotConfig { get; } = new DiscordBotConfig();
public ProxyConfiguration ProxyConfig { get; } = new ProxyConfiguration();
public static UpdateProject Load(string filePath)
{
if (File.Exists(filePath))
return JObject.Parse(File.ReadAllText(filePath)).ToObject<UpdateProject>();
else
return new UpdateProject();
}
public UpdateServerConfig UpdateServerConfig { get; } = new UpdateServerConfig();
public DiscordBotConfig DiscordBotConfig { get; } = new DiscordBotConfig();
public ProxyConfiguration ProxyConfig { get; } = new ProxyConfiguration();
public void Save(string filePath)
{
File.WriteAllText(filePath, JObject.FromObject(this).ToString());
}
public static UpdateProject Load(string filePath)
{
if (File.Exists(filePath))
return JObject.Parse(File.ReadAllText(filePath)).ToObject<UpdateProject>();
else
return new UpdateProject();
}
public void Save(string filePath)
{
File.WriteAllText(filePath, JObject.FromObject(this).ToString());
}
}