/// <summary> /// Initializes a new instance of the TsCollection class with the specific CLR type. /// </summary> /// <param name="type">The CLR collection represented by this instance of the TsCollection.</param> public TsCollection(Type type) : base(type) { var enumerableType = TsType.GetEnumerableType(this.Type); if (enumerableType != null) { this.ItemsType = TsType.Create(enumerableType); } else if (typeof(IEnumerable).IsAssignableFrom(this.Type)) { this.ItemsType = TsType.Any; } else { throw new ArgumentException(string.Format("The type '{0}' is not collection.", this.Type.FullName)); } this.Dimension = GetCollectionDimension(type); }
/// <summary> /// Initializes a new instance of the TsCollection class with the specific CLR type. /// </summary> /// <param name="type">The CLR collection represented by this instance of the TsCollection.</param> public TsCollection(Type type, TsPropertyVisibilityFormatter propertyVisibilityFormatter) : base(type) { var enumerableType = TsType.GetEnumerableType(this.Type); if (enumerableType != null) { this.ItemsType = TsType.Create(enumerableType, propertyVisibilityFormatter); } else if (typeof(IEnumerable).IsAssignableFrom(this.Type)) { this.ItemsType = TsType.Any; } else { throw new ArgumentException($"The type '{this.Type.FullName}' is not collection."); } this.Dimension = GetCollectionDimension(type); }