Пример #1
0
        /*
         * Output the selected fields from the table from rows matching the given where clause,
         * or from all rows if none was given.
         */
        public override void Execute() {
            // List<DBRow> result = new List<DBRow>();
            values = new List<RowValues>();
            foreach(DBFile db in DbFiles) {
                foreach(DBRow row in db.Entries) {
                    if (whereClause != null && !whereClause.Accept(row)) {
                        continue;
                    }
                    RowValues fieldValues = new RowValues();
                    if (AllFields) {
                        row.ForEach(v => { fieldValues.Add(v.Value); });
                    } else {
                        Fields.ForEach(f => fieldValues.Add(row[f].Value));
                    }
                    values.Add(fieldValues);
                }
            }
#if DEBUG
            // Console.WriteLine("{0} lines selected", values.Count);
#endif
            if (!Silent) {
                if (tables.Count > 0) {
                    Console.WriteLine("{0}:", tables[0]);
                }
                Values.ForEach(r => {
                    Console.WriteLine(string.Join(",", r));
                });
            }
        }
Пример #2
0
        public void ReadRowValues(SheetReader sheetReader)
        {
            do
            {
                if (sheetReader.Address == null)
                {
                    continue;
                }

                var cellRef = new CellRef(sheetReader.Address);
                RowValuesByColumRef.Add(cellRef.Column, sheetReader.Value);
                var colNumber = cellRef.ColumnNumber - 1;
                if (!_cellSettersDictionaryForRead.ContainsKey(colNumber))
                {
                    continue;
                }

                var cellValue = sheetReader.Value;
                if (cellValue != null)
                {
                    RowIsPopulated = true;
                    if (RowValues == null)
                    {
                        RowValues = new Dictionary <int, object>();
                    }

                    RowValues.Add(colNumber, cellValue);
                }
            } while (sheetReader.ReadNextInRow());
        }
Пример #3
0
        public Solver(List <List <int> > puzzle)
        {
            for (var i = 0; i < 9; i++)
            {
                RowValues.Add(new List <bool> {
                    false, false, false, false, false, false, false, false, false, false
                });
                ColumnValues.Add(new List <bool> {
                    false, false, false, false, false, false, false, false, false, false
                });
                SquareValues.Add(new List <bool> {
                    false, false, false, false, false, false, false, false, false, false
                });
            }

            this.Puzzle = puzzle;
            this.ConfigureInitialPossibilities();
            this.Solve();
        }