69 lines
2.0 KiB
C#
Executable File
69 lines
2.0 KiB
C#
Executable File
using System;
|
|
using System.Text.Json;
|
|
|
|
namespace ReFuel.Gltf
|
|
{
|
|
public class GltfAsset : GltfObject
|
|
{
|
|
public override GltfObjectKind Kind => GltfObjectKind.Asset;
|
|
public Version Version { get; private set; } = new Version(2, 0);
|
|
public Version? MinVersion { get; private set; } = null;
|
|
public string? Generator { get; private set; } = null;
|
|
public string? Copyright { get; private set; } = null;
|
|
|
|
internal GltfAsset(GltfDocument document) : base(document)
|
|
{
|
|
}
|
|
|
|
internal override void Deserialize(JsonElement element)
|
|
{
|
|
if (element.ValueKind != JsonValueKind.Object)
|
|
throw new Exception("Expected a JSON object.");
|
|
|
|
JsonElement value;
|
|
if (element.TryGetProperty("version", out value))
|
|
{
|
|
string? str = value.GetString();
|
|
if (Version.TryParse(str, out Version? v))
|
|
{
|
|
Version = v;
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("Malformed version string.");
|
|
}
|
|
}
|
|
|
|
if (element.TryGetProperty("minVersion", out value))
|
|
{
|
|
string? str = value.GetString();
|
|
if (Version.TryParse(str, out Version? v))
|
|
{
|
|
MinVersion = v;
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("Malformed version string.");
|
|
}
|
|
}
|
|
|
|
if (element.TryGetProperty("generator", out value))
|
|
{
|
|
Generator = value.GetString();
|
|
}
|
|
|
|
if (element.TryGetProperty("copyright", out value))
|
|
{
|
|
Copyright = value.GetString();
|
|
}
|
|
|
|
DeserializeCommon(element);
|
|
}
|
|
|
|
internal override void Serialize(Utf8JsonWriter writer)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|