mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +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
|
- Fixed Combination.IsModifierDown querying one of its modifiers instead of all of them
|
||||||
|
|
||||||
Removals
|
Removals
|
||||||
|
- Removed DataContract attribute from GenericDataHolder
|
||||||
- Marked EnumHelper as obsolete due to its reimplementation in [DynamicEnums](https://www.nuget.org/packages/DynamicEnums)
|
- Marked EnumHelper as obsolete due to its reimplementation in [DynamicEnums](https://www.nuget.org/packages/DynamicEnums)
|
||||||
|
|
||||||
### MLEM.Ui
|
### MLEM.Ui
|
||||||
|
@ -79,6 +80,7 @@ Improvements
|
||||||
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
- Multi-target net452, making MLEM compatible with MonoGame for consoles
|
||||||
- Added trimming and AOT annotations and made MLEM.Data trimmable
|
- Added trimming and AOT annotations and made MLEM.Data trimmable
|
||||||
- Store a RuntimeTexturePacker packed texture region's source region
|
- Store a RuntimeTexturePacker packed texture region's source region
|
||||||
|
- Use JSON.NET attributes in favor of DataContract and DataMember
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed data texture atlases not allowing most characters in their region names
|
- Fixed data texture atlases not allowing most characters in their region names
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using MLEM.Misc;
|
using MLEM.Misc;
|
||||||
using Newtonsoft.Json;
|
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.
|
/// 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"/>.
|
/// 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>
|
/// </summary>
|
||||||
[DataContract]
|
|
||||||
#if NET7_0_OR_GREATER
|
#if NET7_0_OR_GREATER
|
||||||
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for instantiation of JsonTypeSafeWrapper instances might not be available at runtime.")]
|
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for instantiation of JsonTypeSafeWrapper instances might not be available at runtime.")]
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,7 +14,7 @@ namespace MLEM.Data.Json {
|
||||||
|
|
||||||
private static readonly string[] EmptyStrings = new string[0];
|
private static readonly string[] EmptyStrings = new string[0];
|
||||||
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
[JsonProperty]
|
||||||
private Dictionary<string, JsonTypeSafeWrapper> data;
|
private Dictionary<string, JsonTypeSafeWrapper> data;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MLEM.Data.Json {
|
namespace MLEM.Data.Json {
|
||||||
|
@ -45,12 +44,12 @@ namespace MLEM.Data.Json {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[DataContract]
|
|
||||||
public class JsonTypeSafeWrapper<T> : JsonTypeSafeWrapper {
|
public class JsonTypeSafeWrapper<T> : JsonTypeSafeWrapper {
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override object Value => this.value;
|
public override object Value => this.value;
|
||||||
[DataMember]
|
|
||||||
|
[JsonProperty]
|
||||||
private readonly T value;
|
private readonly T value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace MLEM.Misc {
|
namespace MLEM.Misc {
|
||||||
/// <summary>
|
/// <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.
|
/// 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.
|
/// This <see cref="IGenericDataHolder"/> implemention uses an underlying <see cref="Dictionary{String,Object}"/> that only keeps track of non-default values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataContract]
|
|
||||||
public class GenericDataHolder : IGenericDataHolder {
|
public class GenericDataHolder : IGenericDataHolder {
|
||||||
|
|
||||||
private static readonly string[] EmptyStrings = new string[0];
|
private static readonly string[] EmptyStrings = new string[0];
|
||||||
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
|
||||||
private Dictionary<string, object> data;
|
private Dictionary<string, object> data;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
Loading…
Reference in a new issue