2020-04-22 13:44:49 +02:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using MLEM.Content;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
namespace MLEM.Data.Json {
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <inheritdoc />
|
2020-04-22 13:44:49 +02:00
|
|
|
public class RawJsonReader : RawContentReader {
|
|
|
|
|
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() {
|
|
|
|
return new[] {"json"};
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|