mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
added RawJsonReader to MLEM.Data
This commit is contained in:
parent
9c7f4fcfed
commit
3f89b47eef
1 changed files with 23 additions and 0 deletions
23
MLEM.Data/Json/RawJsonReader.cs
Normal file
23
MLEM.Data/Json/RawJsonReader.cs
Normal file
|
@ -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"};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue