JsonData<T>
Wrapper which contains JSON serialized data along with the JSON data's original type information
to be deserialized later.
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Text.Json;
namespace System.Private.Windows
{
[Serializable]
[NullableContext(1)]
[Nullable(0)]
internal struct JsonData<[Nullable(2)] T> : IJsonData
{
public byte[] JsonBytes {
[IsReadOnly]
get;
set;
}
public string InnerTypeAssemblyQualifiedName {
[IsReadOnly]
get {
return typeof(T).ToTypeName().AssemblyQualifiedName;
}
}
[IsReadOnly]
[RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.Deserialize<TValue>(ReadOnlySpan<Byte>, JsonSerializerOptions)")]
public object Deserialize()
{
object obj;
try {
obj = JsonSerializer.Deserialize<T>((ReadOnlySpan<byte>)JsonBytes, (JsonSerializerOptions)null);
} catch (Exception ex) {
obj = new NotSupportedException(ex.Message);
}
object obj2 = obj;
if (obj2 == null)
throw new InvalidOperationException();
return obj2;
}
}
}