mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Allow adding JsonTypeSafeWrapper instances to JsonTypeSafeGenericDataHolder directly
This commit is contained in:
parent
e812dd7802
commit
92353e40e6
2 changed files with 3 additions and 1 deletions
|
@ -81,6 +81,7 @@ Improvements
|
|||
- Added trimming and AOT annotations and made MLEM.Data trimmable
|
||||
- Store a RuntimeTexturePacker packed texture region's source region
|
||||
- Use JSON.NET attributes in favor of DataContract and DataMember
|
||||
- Allow adding JsonTypeSafeWrapper instances to JsonTypeSafeGenericDataHolder directly
|
||||
|
||||
Fixes
|
||||
- Fixed data texture atlases not allowing most characters in their region names
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace MLEM.Data.Json {
|
|||
/// <summary>
|
||||
/// An <see cref="IGenericDataHolder"/> represents an object that can hold generic key-value based data.
|
||||
/// This class uses <see cref="JsonTypeSafeWrapper"/> for each object stored to ensure that objects with a custom <see cref="JsonConverter"/> get deserialized as an instance of their original type if <see cref="JsonSerializer.TypeNameHandling"/> is not set to <see cref="TypeNameHandling.None"/>.
|
||||
/// Note that, using <see cref="SetData"/>, adding <see cref="JsonTypeSafeWrapper{T}"/> instances directly is also possible.
|
||||
/// </summary>
|
||||
#if NET7_0_OR_GREATER
|
||||
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for instantiation of JsonTypeSafeWrapper instances might not be available at runtime.")]
|
||||
|
@ -25,7 +26,7 @@ namespace MLEM.Data.Json {
|
|||
} else {
|
||||
if (this.data == null)
|
||||
this.data = new Dictionary<string, JsonTypeSafeWrapper>();
|
||||
this.data[key] = JsonTypeSafeWrapper.Of(data);
|
||||
this.data[key] = data as JsonTypeSafeWrapper ?? JsonTypeSafeWrapper.Of(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue