36 lines
921 B
C#
36 lines
921 B
C#
|
using System.IO;
|
||
|
using System.Text.Json;
|
||
|
using System.Text.Json.Serialization;
|
||
|
|
||
|
namespace Palettizer
|
||
|
{
|
||
|
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 GMSprite ImportSprite(FileInfo soundFile)
|
||
|
{
|
||
|
return ImportResource<GMSprite>(soundFile);
|
||
|
}
|
||
|
|
||
|
private static T ImportResource<T>(FileInfo resourceFile)
|
||
|
{
|
||
|
return JsonSerializer.Deserialize<T>(File.ReadAllText(resourceFile.FullName), options);
|
||
|
}
|
||
|
}
|
||
|
}
|