2020-04-22 00:47:09 +02:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
2020-09-16 23:39:01 +02:00
|
|
|
namespace MLEM.Data.Content {
|
2020-05-21 12:53:42 +02:00
|
|
|
/// <inheritdoc />
|
2020-04-22 00:47:09 +02:00
|
|
|
public class XmlReader : RawContentReader {
|
|
|
|
|
2020-05-21 12:53:42 +02:00
|
|
|
/// <inheritdoc />
|
2020-04-22 00:47:09 +02:00
|
|
|
public override bool CanRead(Type t) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-05-21 12:53:42 +02:00
|
|
|
/// <inheritdoc />
|
2022-12-13 13:11:36 +01:00
|
|
|
#if NET6_0_OR_GREATER
|
2022-10-31 18:33:53 +01:00
|
|
|
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026",
|
|
|
|
Justification = "RawContentManager does not support XmlReader in a trimmed or AOT context, so this method is not expected to be called.")]
|
2022-12-13 13:11:36 +01:00
|
|
|
#endif
|
2020-04-22 00:47:09 +02:00
|
|
|
public override object Read(RawContentManager manager, string assetPath, Stream stream, Type t, object existing) {
|
|
|
|
return new XmlSerializer(t).Deserialize(stream);
|
|
|
|
}
|
|
|
|
|
2020-05-21 12:53:42 +02:00
|
|
|
/// <inheritdoc />
|
2020-04-22 00:47:09 +02:00
|
|
|
public override string[] GetFileExtensions() {
|
|
|
|
return new[] {"xml"};
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-06-17 18:23:47 +02:00
|
|
|
}
|