36 lines
925 B
C#
36 lines
925 B
C#
using System.IO;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace GMSAudioConverter
|
|
{
|
|
public static class Importer
|
|
{
|
|
static JsonSerializerOptions options = new JsonSerializerOptions
|
|
{
|
|
PropertyNameCaseInsensitive = true,
|
|
AllowTrailingCommas = true
|
|
};
|
|
|
|
static Importer()
|
|
{
|
|
options.Converters.Add(new JsonStringEnumConverter());
|
|
}
|
|
|
|
public static GMProject ImportProject(FileInfo projectFile)
|
|
{
|
|
return ImportResource<GMProject>(projectFile);
|
|
}
|
|
|
|
public static GMSound ImportSound(FileInfo soundFile)
|
|
{
|
|
return ImportResource<GMSound>(soundFile);
|
|
}
|
|
|
|
private static T ImportResource<T>(FileInfo resourceFile)
|
|
{
|
|
return JsonSerializer.Deserialize<T>(File.ReadAllText(resourceFile.FullName), options);
|
|
}
|
|
}
|
|
}
|