示例#1
0
 /// <summary>
 /// The constructor is the only way to affect value to _splitOccurrences without having Initialized true.
 /// </summary>
 /// <param name="container"></param>
 /// <param name="splitOccurrences"></param>
 public SplitPattern(ColumnIndex container = null, int? splitOccurrences = null)
 {
     Initialized = false;
     Container = container;
     if (splitOccurrences != null)
     {
         _splitOccurrences = (int)splitOccurrences;
     }
 }
示例#2
0
        public void AddRow(List<String> row)
        {
            if (row == null || row.Count == 0)
            {
                return;
            }
            lock (_dataSetLock)
            {
                var newRowIndexValue = RowIndexes.Count == 0
                    ? 0
                    : RowIndexes
                    .Where(i => i.Parent == null)
                    .Max(i => i.Index) + 1;
                var newRowIndex = new RowIndex(newRowIndexValue, this);
                RowIndexes.Add(newRowIndex);
                Debug.WriteLine("DataSet.AddRow, adding row index.");

                var currentMaxColumnIndexValue = ColumnIndexes.Count == 0
                    ? -1
                    : ColumnIndexes
                    .Where(i => i.Parent == null)
                    .Max(i => i.Index);

                // Generate new column indexes if needed.
                for (var n = currentMaxColumnIndexValue + 1; n < row.Count; n++)
                {
                    var columnIndex = new ColumnIndex(n, this);
                    ColumnIndexes.Add(columnIndex);
                    Debug.WriteLine("DataSet.AddRow, adding column index.");
                }

                // Finally, populate cells.
                for (var n = 0; n < row.Count; n++)
                {
                    var columnIndex = ColumnIndexes
                        .Where(i => i.Parent == null)
                        .FirstOrDefault(i => i.Index == n);

                    // By construction, should never happen.
                    if (columnIndex == null)
                    {
                        continue;
                    }

                    var cell = new Cell(newRowIndex, columnIndex, row[n]);
                    Cells.Add(cell);
                    Debug.WriteLine("DataSet.AddRow, adding cell.");
                }
            }
        }