using IPA.Config.Data; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IPA.Config.Stores { /// /// The base interface for a value converter for use by objects generated by /// . /// /// /// 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 /// . /// public interface IValueConverter { /// /// Converts the given object to a . /// /// the object to convert /// a representation of as a structure Value ToValue(object obj); /// /// Converts the given to the object type handled by this converter. /// /// the to deserialize /// the deserialized object object FromValue(Value value); /// /// Gets the type that this handles. /// Type Type { get; } } /// /// A strongly-typed . /// /// the type of object to handle /// public abstract class ValueConverter : IValueConverter { /// /// Converts the given object to a . /// /// the object to convert /// a representation of as a structure /// public abstract Value ToValue(T obj); /// /// Converts the given to the object type handled by this converter. /// /// the to deserialize /// the deserialized object /// public abstract T FromValue(Value value); Value IValueConverter.ToValue(object obj) => ToValue((T)obj); object IValueConverter.FromValue(Value value) => FromValue(value); Type IValueConverter.Type => typeof(T); } }