|
|
@ -72,7 +72,7 @@ namespace IPA.Config.Stores.Converters |
|
|
|
/// <returns>the deserialized value</returns>
|
|
|
|
/// <seealso cref="ValueConverter{T}.FromValue(Value, object)"/>
|
|
|
|
public override T FromValue(Value value, object parent) |
|
|
|
=> impl.FromValue(value, parent); |
|
|
|
=> Deserialize(value, parent); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Serializes <paramref name="obj"/> into a <see cref="Value"/> structure, given <paramref name="parent"/>.
|
|
|
@ -82,9 +82,14 @@ namespace IPA.Config.Stores.Converters |
|
|
|
/// <returns>the <see cref="Value"/> tree that represents <paramref name="obj"/></returns>
|
|
|
|
/// <seealso cref="ValueConverter{T}.ToValue(T, object)"/>
|
|
|
|
public override Value ToValue(T obj, object parent) |
|
|
|
=> impl.ToValue(obj, parent); |
|
|
|
=> Serialize(obj, parent); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A <see cref="ValueConverter{T}"/> for custom value types, serialized identically to the reference types serialized with
|
|
|
|
/// <see cref="GeneratedStore.Generated{T}(Config, bool)"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T">the type of the value to convert</typeparam>
|
|
|
|
public class CustomValueTypeConverter<T> : ValueConverter<T> where T : struct |
|
|
|
{ |
|
|
|
private static readonly GeneratedStoreImpl.SerializeObject<T> serialize |
|
|
@ -92,11 +97,44 @@ namespace IPA.Config.Stores.Converters |
|
|
|
private static readonly GeneratedStoreImpl.DeserializeObject<T> deserialize |
|
|
|
= GeneratedStoreImpl.GetDeserializerDelegate<T>(); |
|
|
|
|
|
|
|
public override T FromValue(Value value, object parent) |
|
|
|
/// <summary>
|
|
|
|
/// Deserializes <paramref name="value"/> into a <typeparamref name="T"/> with the given <paramref name="parent"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="value">the <see cref="Value"/> to deserialize</param>
|
|
|
|
/// <param name="parent">the parent object that will own the deserialized value</param>
|
|
|
|
/// <returns>the deserialized value</returns>
|
|
|
|
/// <seealso cref="ValueConverter{T}.FromValue(Value, object)"/>
|
|
|
|
public static T Deserialize(Value value, object parent) |
|
|
|
=> deserialize(value, parent); |
|
|
|
|
|
|
|
public override Value ToValue(T obj, object parent) |
|
|
|
/// <summary>
|
|
|
|
/// Serializes <paramref name="obj"/> into a corresponding <see cref="Value"/> structure.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="obj">the object to serialize</param>
|
|
|
|
/// <returns>the <see cref="Value"/> tree that represents <paramref name="obj"/></returns>
|
|
|
|
/// <seealso cref="ValueConverter{T}.ToValue(T, object)"/>
|
|
|
|
public static Value Serialize(T obj) |
|
|
|
=> serialize(obj); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Deserializes <paramref name="value"/> into a <typeparamref name="T"/> with the given <paramref name="parent"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="value">the <see cref="Value"/> to deserialize</param>
|
|
|
|
/// <param name="parent">the parent object that will own the deserialized value</param>
|
|
|
|
/// <returns>the deserialized value</returns>
|
|
|
|
/// <seealso cref="ValueConverter{T}.FromValue(Value, object)"/>
|
|
|
|
public override T FromValue(Value value, object parent) |
|
|
|
=> Deserialize(value, parent); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Serializes <paramref name="obj"/> into a <see cref="Value"/> structure, given <paramref name="parent"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="obj">the object to serialize</param>
|
|
|
|
/// <param name="parent">the parent object that owns <paramref name="obj"/></param>
|
|
|
|
/// <returns>the <see cref="Value"/> tree that represents <paramref name="obj"/></returns>
|
|
|
|
/// <seealso cref="ValueConverter{T}.ToValue(T, object)"/>
|
|
|
|
public override Value ToValue(T obj, object parent) |
|
|
|
=> Serialize(obj); |
|
|
|
} |
|
|
|
|
|
|
|
} |