public object[] ReadCsv(string content) { var engine = new MultiRecordEngine(typeof(Salesman), typeof(Customer), typeof(Sale)) { RecordSelector = CustomSelector }; return(engine.ReadString(content)); }
public void MultpleRecordsAdvanced() { var myParserEngine = new MultiRecordEngine(typeof(RawCarrier), typeof(RawOrigin), typeof(RawDestination), typeof(RawShipment), typeof(RawShipmentDetail)) { RecordSelector = CustomRecordSelector }; var testString = @"Carrier|123123|117233|DA||| Origin|61|8120|Manufacturing A |Field Road||DALLAS|TX|9|US Destination|LO|0222|||ADINC| TURNPIKE||NT|NY|11003|US|56 Shipment|M00|| 9.00|Inches| 4.00|Inches| 7.00|Inches|2.000|lb|08/01/2010|15:43|U20|U0||90|1| 2|0001||| ShipmentDetail|LM000|805289078029|ORIGINAL|FR||NR| 2.000|0067|2001"; var result = myParserEngine.ReadString(testString); Check.That(result.Length).IsEqualTo(5); }
public static void Test_Import() { var str = @"10248|VINET|5|04071996|01081996|16071996|3|32.38" + Environment.NewLine + "10249|TOMSP|6|05071996|16081996|10071996|1|11.61" + Environment.NewLine + "ALFKI;Alfreds Futterkiste;Maria Anders;Sales Representative;Obere Str. 57;Berlin;Germany" + Environment.NewLine + "ANATR;Ana Trujillo Emparedados y helados;Ana Trujillo;Owner;Avda. de la Constitución 2222;México D.F.;Mexico" + Environment.NewLine + "10250 |HANAR|4|08071996|05081996|12071996|2|65.83" + Environment.NewLine + "10111314012345"; var engine = new MultiRecordEngine(typeof(Orders), typeof(Customer), typeof(SampleType)); engine.RecordSelector = new RecordTypeSelector(CustomSelector); engine.AfterReadRecord += Engine_AfterReadRecord; var records = engine.ReadString(str); Assert.AreEqual(6, records.Count()); Assert.AreEqual(6, _EventCount); }