Пример #1
0
        internal CsvDataRow(CsvDataTable table, string name) : base(table, name)
        {
            // Table should of type CsvDataTable<>.
            Debug.Assert(table.GetType().GetGenericTypeDefinition() == typeof(CsvDataTable <>));

            _data   = new TCsvData[table.Columns.Count];
            _kindId = CsvData.GetKindID(typeof(TCsvData));
        }
        /// <summary>
        /// Returns the <see cref="CsvDataTable{TCsvData}"/> for the specified type.
        /// </summary>
        /// <typeparam name="T">Type of <see cref="CsvData"/>.</typeparam>
        /// <returns><see cref="CsvDataTable{TCsvData}"/> for the specified type; returns null if not loaded.</returns>
        public CsvDataTable <T> GetTable <T>() where T : CsvData, new()
        {
            var kindId      = CsvData.GetKindID(typeof(T));
            var table       = _tables[kindId];
            var castedTable = table as CsvDataTable <T>;

            Debug.Assert(castedTable != null, "KindID associated with type failed to cast.");
            return(castedTable);
        }
Пример #3
0
        // Prevent the user from initiating a CsvDataTable from here.
        // Therefore forcing them to initiate a strongly typed CsvDataTable<>.
        internal CsvDataTable(Type csvDataType)
        {
            Debug.Assert(csvDataType != null, nameof(csvDataType) + " was null.");
            Debug.Assert(csvDataType.IsAbstract || typeof(CsvData).IsAssignableFrom(csvDataType));

            _csvDataType = csvDataType;
            _kindId      = CsvData.GetKindID(csvDataType);
            // Creates an instance of CsvDataColumnCollection.
            _columns = new CsvDataColumnCollection(csvDataType, this);
            // Creates an instance of CsvDataRowCollection<csvDataType>.
            _rows = CsvDataRowCollection.CreateInternal(csvDataType, this);
        }
        /// <summary>
        /// Returns the <see cref="CsvDataTable"/> for the specified type.
        /// </summary>
        /// <param name="type">Type of <see cref="CsvData"/>.</param>
        /// <returns><see cref="CsvDataTable"/> for the specified type; returns null if not loaded.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="type"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="type"/> is abstract or is does not inherit from <see cref="CsvData"/>.</exception>
        public CsvDataTable GetTable(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (type.IsAbstract || type.BaseType != typeof(CsvData))
            {
                throw new ArgumentException("type must be inherited from CsvData and non-abstract.", nameof(type));
            }

            var kindId = CsvData.GetKindID(type);

            return(_tables[kindId]);
        }
Пример #5
0
 /// <summary/>
 protected abstract void SetDataAtColumnIndex(int index, CsvData data);