From 3f89b47eef0e388ddba353be94f8166fe4d48897 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 22 Apr 2020 13:44:49 +0200 Subject: [PATCH] added RawJsonReader to MLEM.Data --- MLEM.Data/Json/RawJsonReader.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 MLEM.Data/Json/RawJsonReader.cs diff --git a/MLEM.Data/Json/RawJsonReader.cs b/MLEM.Data/Json/RawJsonReader.cs new file mode 100644 index 0000000..2b94b9d --- /dev/null +++ b/MLEM.Data/Json/RawJsonReader.cs @@ -0,0 +1,23 @@ +using System; +using System.IO; +using MLEM.Content; +using Newtonsoft.Json; + +namespace MLEM.Data.Json { + public class RawJsonReader : RawContentReader { + + public override bool CanRead(Type t) { + return true; + } + + 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); + } + + public override string[] GetFileExtensions() { + return new[] {"json"}; + } + + } +} \ No newline at end of file