mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
DataContract usage improvements
This commit is contained in:
parent
810406fb94
commit
63ea3eba90
4 changed files with 5 additions and 10 deletions
|
@ -39,6 +39,7 @@ Fixes
|
|||
- Fixed Combination.IsModifierDown querying one of its modifiers instead of all of them
|
||||
|
||||
Removals
|
||||
- Removed DataContract attribute from GenericDataHolder
|
||||
- Marked EnumHelper as obsolete due to its reimplementation in [DynamicEnums](https://www.nuget.org/packages/DynamicEnums)
|
||||
|
||||
### MLEM.Ui
|
||||
|
@ -79,6 +80,7 @@ Improvements
|
|||
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
||||
- 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
|
||||
|
||||
Fixes
|
||||
- Fixed data texture atlases not allowing most characters in their region names
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using MLEM.Misc;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
@ -8,7 +7,6 @@ namespace MLEM.Data.Json {
|
|||
/// 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"/>.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
#if NET7_0_OR_GREATER
|
||||
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for instantiation of JsonTypeSafeWrapper instances might not be available at runtime.")]
|
||||
#endif
|
||||
|
@ -16,7 +14,7 @@ namespace MLEM.Data.Json {
|
|||
|
||||
private static readonly string[] EmptyStrings = new string[0];
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
[JsonProperty]
|
||||
private Dictionary<string, JsonTypeSafeWrapper> data;
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MLEM.Data.Json {
|
||||
|
@ -45,12 +44,12 @@ namespace MLEM.Data.Json {
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataContract]
|
||||
public class JsonTypeSafeWrapper<T> : JsonTypeSafeWrapper {
|
||||
|
||||
/// <inheritdoc />
|
||||
public override object Value => this.value;
|
||||
[DataMember]
|
||||
|
||||
[JsonProperty]
|
||||
private readonly T value;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace MLEM.Misc {
|
||||
/// <summary>
|
||||
|
@ -7,12 +6,9 @@ namespace MLEM.Misc {
|
|||
/// A lot of MLEM components extend this class to allow for users to add additional data to them easily.
|
||||
/// This <see cref="IGenericDataHolder"/> implemention uses an underlying <see cref="Dictionary{String,Object}"/> that only keeps track of non-default values.
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public class GenericDataHolder : IGenericDataHolder {
|
||||
|
||||
private static readonly string[] EmptyStrings = new string[0];
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
private Dictionary<string, object> data;
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
Loading…
Reference in a new issue