/// <summary> /// Initializes a new instance of the <see cref="NaosCollectionSerializer{TCollection, TElement}"/> class. /// </summary> /// <param name="elementSerializer">The element serializer.</param> public NaosCollectionSerializer(IBsonSerializer <TElement> elementSerializer) { DeserializationConverterFuncBySerializedType.ContainsKey(typeof(TCollection)).Named(Invariant($"{typeof(TCollection)}-mustBeSupportedCollectionType")).Must().BeTrue(); this.underlyingSerializer = elementSerializer == null ? new ReadOnlyCollectionSerializer <TElement>() : new ReadOnlyCollectionSerializer <TElement>(elementSerializer); }
/// <summary> /// Initializes a new instance of the <see cref="CollectionBsonSerializer{TCollection,TElement}"/> class. /// </summary> /// <param name="elementSerializer">The element serializer.</param> public CollectionBsonSerializer( IBsonSerializer <TElement> elementSerializer) { if (!typeof(TCollection).IsClosedSystemCollectionType()) { throw new ArgumentException("'typeof(TCollection).IsSystemCollectionType()' is false"); } this.underlyingSerializer = elementSerializer == null ? new ReadOnlyCollectionSerializer <TElement>() : new ReadOnlyCollectionSerializer <TElement>(elementSerializer); }