public SequenceCollectionTypeInfo(Type collectionType) { collectionType.ThrowIfNull(nameof(collectionType)); if (!typeof(IList).IsAssignableFrom(collectionType)) { throw new ArgumentException(string.Format("{0} is not a {1}.", collectionType.Name, typeof(IList).Name)); } genericType = SerializationUtilities.GetGenericType(collectionType, typeof(IList <>)); elementType = (genericType != null) ? genericType.GetGenericArguments()[0] : typeof(object); isTypeConstrained = elementType != typeof(object); isArray = collectionType.IsArray; }
public LookupCollectionTypeInfo(Type collectionType) { collectionType.ThrowIfNull(nameof(collectionType)); if (!typeof(IDictionary).IsAssignableFrom(collectionType)) { throw new ArgumentException(string.Format("{0} is not a {1}.", collectionType.Name, typeof(IDictionary).Name)); } genericType = SerializationUtilities.GetGenericType(collectionType, typeof(IDictionary <,>)); genericParams = (genericType != null) ? genericType.GetGenericArguments() : null; keyType = (genericParams != null) ? genericParams[0] : typeof(object); valueType = (genericParams != null) ? genericParams[1] : typeof(object); isKeyTypeConstrained = (genericParams != null) && (keyType != typeof(object)); isValueTypeConstrained = (genericParams != null) && (valueType != typeof(object)); }