2020-04-22 13:44:49 +02:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
2020-09-16 23:39:01 +02:00
|
|
|
namespace MLEM.Data.Content {
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <inheritdoc />
|
2020-09-17 01:59:08 +02:00
|
|
|
public class JsonReader : RawContentReader {
|
2020-04-22 13:44:49 +02:00
|
|
|
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <inheritdoc />
|
2020-04-22 13:44:49 +02:00
|
|
|
public override bool CanRead(Type t) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <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);
|
|
|
|
}
|
|
|
|
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <inheritdoc />
|
2020-04-22 13:44:49 +02:00
|
|
|
public override string[] GetFileExtensions() {
|
2020-09-16 23:24:03 +02:00
|
|
|
return new[] {"json", "json5", "jsonc"};
|
2020-04-22 13:44:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|