1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-05 06:49:09 +01:00
MLEM/MLEM.Data/Content/JsonReader.cs

27 lines
733 B
C#
Raw Normal View History

2020-04-22 13:44:49 +02:00
using System;
using System.IO;
using Newtonsoft.Json;
namespace MLEM.Data.Content {
/// <inheritdoc />
public class JsonReader : RawContentReader {
2020-04-22 13:44:49 +02:00
/// <inheritdoc />
2020-04-22 13:44:49 +02:00
public override bool CanRead(Type t) {
return true;
}
/// <inheritdoc />
2020-04-22 13:44:49 +02:00
public override object Read(RawContentManager manager, string assetPath, Stream stream, Type t, object existing) {
using (var reader = new JsonTextReader(new StreamReader(stream)))
return manager.GetJsonSerializer().Deserialize(reader);
}
/// <inheritdoc />
2020-04-22 13:44:49 +02:00
public override string[] GetFileExtensions() {
return new[] {"json", "json5", "jsonc"};
2020-04-22 13:44:49 +02:00
}
}
2022-06-17 18:23:47 +02:00
}