Ejemplo n.º 1
0
        public static TableLine FromStringCollection(IEnumerable <string> collection)
        {
            var tableLine = new TableLine();
            var props     = tableLine.GetType().GetProperties();

            foreach (var zip in collection.Zip(props, (s, p) => new { s, p }))
            {
                zip.p.SetValue(tableLine, zip.s);
            }

            return(tableLine);
        }
Ejemplo n.º 2
0
 private void BeginDeviceBuildingFrom(TableLine line)
 {
     try
     {
         device = new Device()
         {
             Name     = line.Name.Trim(),
             Count    = int.Parse(line.CountString.Trim()),
             Supplier = line.Supplier.Trim()
         };
     }
     catch (FormatException ex)
     {
         throw new FormatException($"Неверный формат у строки {line}.", ex);
     }
 }
Ejemplo n.º 3
0
		private static IEnumerable<TableLine> GetLines(string documentPath)
		{
			using (var document = DocX.Load(File.OpenRead(documentPath)))
			{
				var detector = new HeaderDetector();
				var bidTables = document.Tables.Where(t => IsBidTable(t, detector));

				foreach (var table in bidTables)
				{
					IEnumerable<Row> rowsWithoutHeader = table.Rows.Skip(1);

					foreach (var row in rowsWithoutHeader)
					{
						yield return TableLine.FromStringCollection(row.GetValues());
					}
				}
			}
		}
Ejemplo n.º 4
0
 private void Append(TableLine line)
 {
     device.Name     += line.Name;
     device.Supplier += line.Supplier;
 }