diff --git a/IPA.Loader/Config/Stores/CollectionConverter.cs b/IPA.Loader/Config/Stores/CollectionConverter.cs index 29a47794..5b91ef5e 100644 --- a/IPA.Loader/Config/Stores/CollectionConverter.cs +++ b/IPA.Loader/Config/Stores/CollectionConverter.cs @@ -89,12 +89,12 @@ namespace IPA.Config.Stores.Converters /// the type of the colleciton /// the type of the converter to use for /// - public class CollectionConverter : CollectionConverter + public sealed class CollectionConverter : CollectionConverter where TCollection : ICollection where TConverter : ValueConverter, new() { /// - /// Creates a using the default converter for the + /// Creates a using a default constructed /// element type. Equivalent to calling /// with a default-constructed . /// @@ -102,28 +102,136 @@ namespace IPA.Config.Stores.Converters public CollectionConverter() : base(new TConverter()) { } } + /// + /// A for an , creating a when deserializing. + /// + /// the element type of the + /// public class ISetConverter : CollectionConverter> { + /// + /// Creates an using the default converter for . + /// + /// public ISetConverter() : base() { } + /// + /// Creates an using the specified underlying converter for values. + /// + /// the underlying to use for the values public ISetConverter(ValueConverter underlying) : base(underlying) { } + /// + /// Creates a new (a ) for deserialization. + /// + /// the size to initialize it to + /// the object that will own the new object + /// the new protected override ISet Create(int size, object parent) => new HashSet(); } + /// + /// An which default constructs a converter for use as the value converter. + /// + /// the value type of the collection + /// the type of the converter to use for + /// + public sealed class ISetConverter : ISetConverter + where TConverter : ValueConverter, new() + { + /// + /// Creates an using a default constructed + /// element type. Equivalent to calling + /// with a default-constructed . + /// + /// + public ISetConverter() : base(new TConverter()) { } + } + /// + /// A for a . + /// + /// the element type of the + /// public class ListConverter : CollectionConverter> { + /// + /// Creates an using the default converter for . + /// + /// public ListConverter() : base() { } + /// + /// Creates an using the specified underlying converter for values. + /// + /// the underlying to use for the values public ListConverter(ValueConverter underlying) : base(underlying) { } + /// + /// Creates a new for deserialization. + /// + /// the size to initialize it to + /// the object that will own the new object + /// the new protected override List Create(int size, object parent) => new List(size); } + /// + /// A which default constructs a converter for use as the value converter. + /// + /// the value type of the collection + /// the type of the converter to use for + /// + public sealed class ListConverter : ListConverter + where TConverter : ValueConverter, new() + { + /// + /// Creates an using a default constructed + /// element type. Equivalent to calling + /// with a default-constructed . + /// + /// + public ListConverter() : base(new TConverter()) { } + } + /// + /// A for an , creating a when deserializing. + /// + /// the element type of the + /// public class IListConverter : CollectionConverter> { + /// + /// Creates an using the default converter for . + /// + /// public IListConverter() : base() { } + /// + /// Creates an using the specified underlying converter for values. + /// + /// the underlying to use for the values public IListConverter(ValueConverter underlying) : base(underlying) { } + /// + /// Creates a new (a ) for deserialization. + /// + /// the size to initialize it to + /// the object that will own the new object + /// the new protected override IList Create(int size, object parent) => new List(size); } + /// + /// An which default constructs a converter for use as the value converter. + /// + /// the value type of the collection + /// the type of the converter to use for + /// + public sealed class IListConverter : IListConverter + where TConverter : ValueConverter, new() + { + /// + /// Creates an using a default constructed + /// element type. Equivalent to calling + /// with a default-constructed . + /// + /// + public IListConverter() : base(new TConverter()) { } + } } diff --git a/IPA.Loader/Config/Stores/Converters.cs b/IPA.Loader/Config/Stores/Converters.cs index 5f5a0a0b..c28474c9 100644 --- a/IPA.Loader/Config/Stores/Converters.cs +++ b/IPA.Loader/Config/Stores/Converters.cs @@ -179,7 +179,7 @@ namespace IPA.Config.Stores.Converters /// the underlying type of the /// the type to use as an underlying converter /// - public class NullableConverter : NullableConverter + public sealed class NullableConverter : NullableConverter where T : struct where TConverter : ValueConverter, new() {