convert to c#
This commit is contained in:
33
ModpackUpdater.Model/ModpackInfo.cs
Normal file
33
ModpackUpdater.Model/ModpackInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace ModpackUpdater.Model;
|
||||
|
||||
public class ModpackInfo
|
||||
{
|
||||
private const string FILENAME_MODPACKINFO = "modpack-info.json";
|
||||
|
||||
[JsonConverter(typeof(VersionConverter))]
|
||||
public Version Version { get; set; }
|
||||
|
||||
public void Save(string mcRoot)
|
||||
{
|
||||
File.WriteAllText(Conversions.ToString(GetFilePath(mcRoot)), JsonConvert.SerializeObject(this));
|
||||
}
|
||||
|
||||
public static ModpackInfo Load(string mcRoot)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<ModpackInfo>(File.ReadAllText(Conversions.ToString(GetFilePath(mcRoot))));
|
||||
}
|
||||
|
||||
public static bool HasModpackInfo(string mcRoot)
|
||||
{
|
||||
return File.Exists(Conversions.ToString(GetFilePath(mcRoot)));
|
||||
}
|
||||
|
||||
private static object GetFilePath(string mcRoot)
|
||||
{
|
||||
return Path.Combine(mcRoot, FILENAME_MODPACKINFO);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user