WriteCollection takes IEnumerable<T>, WriteMap takes IEnumerable<KeyValuePair<K, V>> to work around broken collection type hierarchy.