diff --git a/IPA.Loader/Config/Stores/Converters.cs b/IPA.Loader/Config/Stores/Converters.cs index 853fd29f..8d92f6f0 100644 --- a/IPA.Loader/Config/Stores/Converters.cs +++ b/IPA.Loader/Config/Stores/Converters.cs @@ -34,6 +34,11 @@ namespace IPA.Config.Stores.Converters null; } + /// + /// A for objects normally serialized to config via . + /// + /// the same type parameter that would be passed into + /// public class CustomObjectConverter : ValueConverter where T : class { private interface IImpl @@ -46,7 +51,7 @@ namespace IPA.Config.Stores.Converters private static readonly GeneratedStore.GeneratedStoreCreator creator = GeneratedStore.GetCreator(typeof(T)); public T FromValue(Value value, object parent) - { // lots of casting here, but it works i promise + { // lots of casting here, but it works i promise (parent can be a non-IGeneratedStore, however it won't necessarily behave then) var obj = creator(parent as GeneratedStore.IGeneratedStore) as U; obj.Deserialize(value); return obj; @@ -64,15 +69,43 @@ namespace IPA.Config.Stores.Converters private static readonly IImpl impl = (IImpl)Activator.CreateInstance( typeof(Impl<>).MakeGenericType(GeneratedStore.GetGeneratedType(typeof(T)))); + /// + /// Deserializes into a with the given . + /// + /// the to deserialize + /// the parent object that will own the deserialized value + /// the deserialized value + /// public static T Deserialize(Value value, object parent) => impl.FromValue(value, parent); + /// + /// Serializes into a structure, given . + /// + /// the object to serialize + /// the parent object that owns + /// the tree that represents + /// public static Value Serialize(T obj, object parent) => impl.ToValue(obj, parent); + /// + /// Deserializes into a with the given . + /// + /// the to deserialize + /// the parent object that will own the deserialized value + /// the deserialized value + /// public override T FromValue(Value value, object parent) => impl.FromValue(value, parent); + /// + /// Serializes into a structure, given . + /// + /// the object to serialize + /// the parent object that owns + /// the tree that represents + /// public override Value ToValue(T obj, object parent) => impl.ToValue(obj, parent); } diff --git a/IPA.Loader/Config/Stores/ValueConverter.cs b/IPA.Loader/Config/Stores/ValueConverter.cs index c0f8e0db..ec5b9628 100644 --- a/IPA.Loader/Config/Stores/ValueConverter.cs +++ b/IPA.Loader/Config/Stores/ValueConverter.cs @@ -8,10 +8,17 @@ namespace IPA.Config.Stores /// . /// /// + /// /// The object returned from , if fed into , /// should return equivalent structures. Similarly, if the result of /// is fed into , the resulting object should be equivalent to the one passed to /// . + /// + /// + /// The parent parameter to and should + /// be (ideally) the the top of the serialization tree, or some other generated object in that tree, rather than some arbitrary + /// object in the middle that is not managed by the generatd config system. + /// /// public interface IValueConverter {