Browse Source

Added lots of documentation for the CollectionConverters

pull/46/head
Anairkoen Schno 5 years ago
parent
commit
426395dfe7
2 changed files with 111 additions and 3 deletions
  1. +110
    -2
      IPA.Loader/Config/Stores/CollectionConverter.cs
  2. +1
    -1
      IPA.Loader/Config/Stores/Converters.cs

+ 110
- 2
IPA.Loader/Config/Stores/CollectionConverter.cs View File

@ -89,12 +89,12 @@ namespace IPA.Config.Stores.Converters
/// <typeparam name="TCollection">the type of the colleciton</typeparam>
/// <typeparam name="TConverter">the type of the converter to use for <typeparamref name="T"/></typeparam>
/// <seealso cref="CollectionConverter{T, TCollection}"/>
public class CollectionConverter<T, TCollection, TConverter> : CollectionConverter<T, TCollection>
public sealed class CollectionConverter<T, TCollection, TConverter> : CollectionConverter<T, TCollection>
where TCollection : ICollection<T>
where TConverter : ValueConverter<T>, new()
{
/// <summary>
/// Creates a <see cref="CollectionConverter{T, TCollection}"/> using the default converter for the
/// Creates a <see cref="CollectionConverter{T, TCollection}"/> using a default constructed <typeparamref name="TConverter"/>
/// element type. Equivalent to calling <see cref="CollectionConverter{T, TCollection}.CollectionConverter(ValueConverter{T})"/>
/// with a default-constructed <typeparamref name="TConverter"/>.
/// </summary>
@ -102,28 +102,136 @@ namespace IPA.Config.Stores.Converters
public CollectionConverter() : base(new TConverter()) { }
}
/// <summary>
/// A <see cref="CollectionConverter{T, TCollection}"/> for an <see cref="ISet{T}"/>, creating a <see cref="HashSet{T}"/> when deserializing.
/// </summary>
/// <typeparam name="T">the element type of the <see cref="ISet{T}"/></typeparam>
/// <seealso cref="CollectionConverter{T, TCollection}"/>
public class ISetConverter<T> : CollectionConverter<T, ISet<T>>
{
/// <summary>
/// Creates an <see cref="ISetConverter{T}"/> using the default converter for <typeparamref name="T"/>.
/// </summary>
/// <seealso cref="CollectionConverter{T, TCollection}.CollectionConverter()"/>
public ISetConverter() : base() { }
/// <summary>
/// Creates an <see cref="ISetConverter{T}"/> using the specified underlying converter for values.
/// </summary>
/// <param name="underlying">the underlying <see cref="ValueConverter{T}"/> to use for the values</param>
public ISetConverter(ValueConverter<T> underlying) : base(underlying) { }
/// <summary>
/// Creates a new <see cref="ISet{T}"/> (a <see cref="HashSet{T}"/>) for deserialization.
/// </summary>
/// <param name="size">the size to initialize it to</param>
/// <param name="parent">the object that will own the new object</param>
/// <returns>the new <see cref="ISet{T}"/></returns>
protected override ISet<T> Create(int size, object parent)
=> new HashSet<T>();
}
/// <summary>
/// An <see cref="ISetConverter{T}"/> which default constructs a converter for use as the value converter.
/// </summary>
/// <typeparam name="T">the value type of the collection</typeparam>
/// <typeparam name="TConverter">the type of the converter to use for <typeparamref name="T"/></typeparam>
/// <seealso cref="ISetConverter{T}"/>
public sealed class ISetConverter<T, TConverter> : ISetConverter<T>
where TConverter : ValueConverter<T>, new()
{
/// <summary>
/// Creates an <see cref="ISetConverter{T}"/> using a default constructed <typeparamref name="TConverter"/>
/// element type. Equivalent to calling <see cref="ISetConverter{T}.ISetConverter(ValueConverter{T})"/>
/// with a default-constructed <typeparamref name="TConverter"/>.
/// </summary>
/// <seealso cref="ISetConverter{T}.ISetConverter(ValueConverter{T})"/>
public ISetConverter() : base(new TConverter()) { }
}
/// <summary>
/// A <see cref="CollectionConverter{T, TCollection}"/> for a <see cref="List{T}"/>.
/// </summary>
/// <typeparam name="T">the element type of the <see cref="List{T}"/></typeparam>
/// <seealso cref="CollectionConverter{T, TCollection}"/>
public class ListConverter<T> : CollectionConverter<T, List<T>>
{
/// <summary>
/// Creates an <see cref="ListConverter{T}"/> using the default converter for <typeparamref name="T"/>.
/// </summary>
/// <seealso cref="CollectionConverter{T, TCollection}.CollectionConverter()"/>
public ListConverter() : base() { }
/// <summary>
/// Creates an <see cref="ListConverter{T}"/> using the specified underlying converter for values.
/// </summary>
/// <param name="underlying">the underlying <see cref="ValueConverter{T}"/> to use for the values</param>
public ListConverter(ValueConverter<T> underlying) : base(underlying) { }
/// <summary>
/// Creates a new <see cref="List{T}"/> for deserialization.
/// </summary>
/// <param name="size">the size to initialize it to</param>
/// <param name="parent">the object that will own the new object</param>
/// <returns>the new <see cref="List{T}"/></returns>
protected override List<T> Create(int size, object parent)
=> new List<T>(size);
}
/// <summary>
/// A <see cref="ListConverter{T}"/> which default constructs a converter for use as the value converter.
/// </summary>
/// <typeparam name="T">the value type of the collection</typeparam>
/// <typeparam name="TConverter">the type of the converter to use for <typeparamref name="T"/></typeparam>
/// <seealso cref="ListConverter{T}"/>
public sealed class ListConverter<T, TConverter> : ListConverter<T>
where TConverter : ValueConverter<T>, new()
{
/// <summary>
/// Creates an <see cref="ListConverter{T}"/> using a default constructed <typeparamref name="TConverter"/>
/// element type. Equivalent to calling <see cref="ListConverter{T}.ListConverter(ValueConverter{T})"/>
/// with a default-constructed <typeparamref name="TConverter"/>.
/// </summary>
/// <seealso cref="ListConverter{T}.ListConverter(ValueConverter{T})"/>
public ListConverter() : base(new TConverter()) { }
}
/// <summary>
/// A <see cref="CollectionConverter{T, TCollection}"/> for an <see cref="IList{T}"/>, creating a <see cref="List{T}"/> when deserializing.
/// </summary>
/// <typeparam name="T">the element type of the <see cref="IList{T}"/></typeparam>
/// <seealso cref="CollectionConverter{T, TCollection}"/>
public class IListConverter<T> : CollectionConverter<T, IList<T>>
{
/// <summary>
/// Creates an <see cref="IListConverter{T}"/> using the default converter for <typeparamref name="T"/>.
/// </summary>
/// <seealso cref="CollectionConverter{T, TCollection}.CollectionConverter()"/>
public IListConverter() : base() { }
/// <summary>
/// Creates an <see cref="IListConverter{T}"/> using the specified underlying converter for values.
/// </summary>
/// <param name="underlying">the underlying <see cref="ValueConverter{T}"/> to use for the values</param>
public IListConverter(ValueConverter<T> underlying) : base(underlying) { }
/// <summary>
/// Creates a new <see cref="IList{T}"/> (a <see cref="List{T}"/>) for deserialization.
/// </summary>
/// <param name="size">the size to initialize it to</param>
/// <param name="parent">the object that will own the new object</param>
/// <returns>the new <see cref="IList{T}"/></returns>
protected override IList<T> Create(int size, object parent)
=> new List<T>(size);
}
/// <summary>
/// An <see cref="IListConverter{T}"/> which default constructs a converter for use as the value converter.
/// </summary>
/// <typeparam name="T">the value type of the collection</typeparam>
/// <typeparam name="TConverter">the type of the converter to use for <typeparamref name="T"/></typeparam>
/// <seealso cref="IListConverter{T}"/>
public sealed class IListConverter<T, TConverter> : IListConverter<T>
where TConverter : ValueConverter<T>, new()
{
/// <summary>
/// Creates an <see cref="IListConverter{T}"/> using a default constructed <typeparamref name="TConverter"/>
/// element type. Equivalent to calling <see cref="IListConverter{T}.IListConverter(ValueConverter{T})"/>
/// with a default-constructed <typeparamref name="TConverter"/>.
/// </summary>
/// <seealso cref="IListConverter{T}.IListConverter(ValueConverter{T})"/>
public IListConverter() : base(new TConverter()) { }
}
}

+ 1
- 1
IPA.Loader/Config/Stores/Converters.cs View File

@ -179,7 +179,7 @@ namespace IPA.Config.Stores.Converters
/// <typeparam name="T">the underlying type of the <see cref="Nullable{T}"/></typeparam>
/// <typeparam name="TConverter">the type to use as an underlying converter</typeparam>
/// <seealso cref="NullableConverter{T}"/>
public class NullableConverter<T, TConverter> : NullableConverter<T>
public sealed class NullableConverter<T, TConverter> : NullableConverter<T>
where T : struct
where TConverter : ValueConverter<T>, new()
{


Loading…
Cancel
Save