示例#1
0
        /// <summary>
        /// Adds a column to a bundle identified by a string <paramref name="identifier"/>.
        /// </summary>
        /// <param name="identifier">Identifier (key) to identifiy the bundle to which the data column is added.</param>
        /// <param name="column">Column to add. Must have ColumnKind.V and a group number equal to <see cref="GroupNumber"/>. Otherwise, this column will be removed in the next call to <see cref="Update"/>.</param>
        public void AddDataColumn(string identifier, IReadableColumn column)
        {
            if (null == identifier)
            {
                throw new ArgumentNullException("identifier");
            }

            if (identifier == "" && !_dataColumnBundles.ContainsKey(identifier))
            {
                _dataColumnBundles.Add("", new ColumnBundleInfo());
            }

            if (!_dataColumnBundles.ContainsKey(identifier))
            {
                throw new InvalidOperationException(string.Format("Identifier {0} was not found in the collection", identifier));
            }

            var bundle = _dataColumnBundles[identifier];

            if (null != column)
            {
                InternalAddDataColumnNoClone(bundle, ReadableColumnProxyBase.FromColumn(column));
                _isDirty = true;
            }
        }
示例#2
0
        /// <summary>
        /// Sets the data columns in the bundle identified by <paramref name="identifier"/>.
        /// </summary>
        /// <param name="identifier">The identifier of the bundle in which to set the data columns.</param>
        /// <param name="columns">The columns.</param>
        /// <exception cref="System.ArgumentNullException">
        /// identifier
        /// or
        /// column
        /// </exception>
        public void SetDataColumns(string identifier, IEnumerable <DataColumn> columns)
        {
            if (null == identifier)
            {
                throw new ArgumentNullException("identifier");
            }
            if (null == columns)
            {
                throw new ArgumentNullException("column");
            }

            SetDataColumns(identifier, columns.Select(column => ReadableColumnProxyBase.FromColumn(column)));
        }
示例#3
0
        /// <summary>
        /// Sets the data column as the only data column of the bundle identified by <paramref name="identifier"/>.
        /// </summary>
        /// <param name="identifier">The identifier of the bundle in which to set the data column.</param>
        /// <param name="column">The data column to set.</param>
        /// <exception cref="System.ArgumentNullException">
        /// identifier
        /// or
        /// column
        /// </exception>
        public void SetDataColumn(string identifier, DataColumn column)
        {
            if (null == identifier)
            {
                throw new ArgumentNullException("identifier");
            }
            if (null == column)
            {
                throw new ArgumentNullException("column");
            }

            SetDataColumns(identifier, new IReadableColumnProxy[] { ReadableColumnProxyBase.FromColumn(column) });
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataTableMultipleColumnProxy"/> class. The selected collections determine which columns and rows contribute to this instance.
        /// The group number is determined by the first selected column (or, if no column is selected, by the first column of the data table).
        /// </summary>
        /// <param name="identifier">The identifier of the bundle of columns that are initially set with this constructor.</param>
        /// <param name="table">The underlying table.</param>
        /// <param name="selectedDataRows">The selected data rows.</param>
        /// <param name="selectedDataColumns">The selected data columns.</param>
        /// <exception cref="System.ArgumentNullException">table must not be null.</exception>
        public DataTableMultipleColumnProxy(string identifier, DataTable table, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedDataColumns)
        {
            if (null == identifier)
            {
                throw new ArgumentNullException("identifier");
            }

            if (null == table)
            {
                throw new ArgumentNullException("table");
            }

            _dataColumnBundles = new Dictionary <string, ColumnBundleInfo>();

            _dataTable = new DataTableProxy(table)
            {
                ParentObject = this
            };

            _groupNumber = 0;

            if (null != selectedDataColumns && selectedDataColumns.Count > 0)
            {
                _groupNumber = table.DataColumns.GetColumnGroup(table[selectedDataColumns[0]]);
            }

            var bundle = new ColumnBundleInfo();

            _dataColumnBundles.Add(identifier, bundle);

            int maxRowCount = 0;

            if (selectedDataColumns != null && selectedDataColumns.Count > 0)
            {
                for (int i = 0; i < selectedDataColumns.Count; ++i)
                {
                    var col = table[selectedDataColumns[i]];
                    if (table.DataColumns.GetColumnGroup(col) == _groupNumber)
                    {
                        InternalAddDataColumnNoClone(bundle, ReadableColumnProxyBase.FromColumn(col));
                        maxRowCount = Math.Max(maxRowCount, col.Count);
                    }
                }
            }
            else // nothing selected - use all columns of group number 0
            {
                for (int i = 0; i < table.DataColumnCount; ++i)
                {
                    var col = table[i];
                    if (table.DataColumns.GetColumnGroup(col) == _groupNumber)
                    {
                        InternalAddDataColumnNoClone(bundle, ReadableColumnProxyBase.FromColumn(col));
                        maxRowCount = Math.Max(maxRowCount, col.Count);
                    }
                }
            }

            _useAllAvailableDataRows = null == selectedDataRows || selectedDataRows.Count == 0;

            _participatingDataRows = new AscendingIntegerCollection(_useAllAvailableDataRows ? ContiguousIntegerRange.FromStartAndCount(0, maxRowCount) : selectedDataRows);
        }