private object[] SetupMapping(int count, DataColumnCollection columnCollection, DataColumn chapterColumn, object chapterValue)
{
object[] dataValues = new object[count];
if (null == _indexMap)
{
int mappingCount = columnCollection.Count;
bool hasChapters = (null != _chapterMap);
if ((count != mappingCount) || hasChapters)
{
_mappedDataValues = new object[mappingCount];
if (hasChapters)
{
_mappedMode = MapChapters;
_mappedLength = count;
}
else
{
_mappedMode = MapDifferentSize;
_mappedLength = Math.Min(count, mappingCount);
}
}
else
{
_mappedMode = MapExactMatch; /* _mappedLength doesn't matter */
}
}
else
{
_mappedDataValues = new object[columnCollection.Count];
_mappedMode = ((null == _chapterMap) ? MapReorderedValues : MapChaptersReordered);
_mappedLength = count;
}
if (null != chapterColumn)
{ // value from parent tracked into child table
_mappedDataValues[chapterColumn.Ordinal] = chapterValue;
}
return dataValues;
}
}