Collections

Supported types

Arrays and lists:

  • T[]

  • List<T>

  • IEnumerable<T> (backed by T[])

  • IReadOnlyList<T>(backed by T[])

  • IReadOnlyCollection<T>(backed by T[])

  • ICollection<T> (backed by List<T>)

  • IList<T>(backed by List<T>)

Dictionaries:

  • Dictionary<TKey, TValue>

  • IDictionary<TKey, TValue> (backed by Dictionary)

  • IReadOnlyDictionary<TKey, TValue> (backed by Dictionary)

Sets:

  • HashSet<T>

  • ISet<T> (backed by HashSet)

Collections can have classes, structs and other collections as elements.

Binder requirements

Collections require binders defined for element types (both keys and values in case of dictionaries).

Node requirements

Array or object node. Empty nodes are converted to empty collections.

Null node handling

An empty collection is returned unless explictly required.

Nulls are not valid as dictionary keys.

Error handling

Any element binding failure results in complete collection binding failure.

Comparer customization

A custom element comparer (such as StringComparer.OrdinalIgnoreCase for case-insensitive dictionary keys) can be achieved by wrapping the collection in a custom type and utilizing the constructor binding convention.

Last updated