internal DataKey(DataColumn[] columns, bool copyColumns)
{
if (columns == null)
{
throw ExceptionBuilder.ArgumentNull(nameof(columns));
}
if (columns.Length == 0)
{
throw ExceptionBuilder.KeyNoColumns();
}
if (columns.Length > maxColumns)
{
throw ExceptionBuilder.KeyTooManyColumns(maxColumns);
}
for (int i = 0; i < columns.Length; i++)
{
if (columns[i] == null)
{
throw ExceptionBuilder.ArgumentNull("column");
}
}
for (int i = 0; i < columns.Length; i++)
{
for (int j = 0; j < i; j++)
{
if (columns[i] == columns[j])
{
throw ExceptionBuilder.KeyDuplicateColumns(columns[i].ColumnName);
}
}
}
if (copyColumns)
{
// Need to make a copy of all columns
_columns = new DataColumn[columns.Length];
for (int i = 0; i < columns.Length; i++)
{
_columns[i] = columns[i];
}
}
else
{
// take ownership of the array passed in
_columns = columns;
}
CheckState();
}