//-> File:Example.cs /// <summary> /// Execute the engine and get some results /// </summary> public override void Run() { var engine = new FixedFileEngine<Customer>(); Customer[] result = engine.ReadFile("input.txt"); foreach (var detail in result) this.Console.WriteLine(" Client: {0}, Name: {1}", detail.CustId, detail.Name); }
public void SimpleTest2() { FixedFileEngine engine = new FixedFileEngine(typeof(CustomersFixed)); Assert.AreEqual(91, FileTest.Good.CustomersFixed.ReadWithEngine(engine).Length); engine.Options.RecordCondition.Condition = RecordCondition.IncludeIfBegins; engine.Options.RecordCondition.Selector = "F"; Assert.AreEqual(8, FileTest.Good.CustomersFixed.ReadWithEngine(engine).Length); }
public void SimpleTest2() { FixedFileEngine engine = new FixedFileEngine(typeof(CustomersFixed)); Assert.AreEqual(91, Common.ReadTest(engine, @"Good\CustomersFixed.txt").Length); engine.Options.RecordCondition.Condition = RecordCondition.IncludeIfBegins; engine.Options.RecordCondition.Selector = "F"; Assert.AreEqual(8, Common.ReadTest(engine, @"Good\CustomersFixed.txt").Length); }
//-> /File public override void Run() { //-> File:Example.cs var engine = new FixedFileEngine<Customer>(); var result = engine.ReadFile("input.txt"); foreach (var detail in result) Console.WriteLine(" Client: {0}, Name: '{1}'", detail.CustId, detail.Name); //-> /File }
public static FileHelperEngine GetEngineForType(Type recordType) { FileHelperEngine rtnVal; if (recordType.GetCustomAttributes(false).Count(p => p.GetType() == typeof(DelimitedRecordAttribute)) == 1) rtnVal = new DelimitedFileEngine(recordType); else if (recordType.GetCustomAttributes(false).Count(p => p.GetType() == typeof(FixedLengthRecordAttribute)) == 1) rtnVal = new FixedFileEngine(recordType); else throw new InvalidOperationException(String.Format("Record type {0} is not a Filehelpers class", recordType)); return rtnVal; }
public void SimpleTest() { var engine = new FixedFileEngine<CustomersFixed>(); Assert.AreEqual(91, FileTest.Good.CustomersFixed.ReadWithEngine(engine).Length); engine.Options.IgnoreFirstLines = 10; Assert.AreEqual(81, FileTest.Good.CustomersFixed.ReadWithEngine(engine).Length); engine.Options.IgnoreLastLines = 6; Assert.AreEqual(75, FileTest.Good.CustomersFixed.ReadWithEngine(engine).Length); Assert.AreEqual(183, engine.Options.RecordLength); }
public override void Run() { //-> File:Example.cs var engine = new FixedFileEngine<Customer>(); Customer[] result = engine.ReadFile("input.txt"); foreach (var detail in result) { this.Console.WriteLine(" Client: {0}, Date: {1}", detail.CustId, detail.AddedDate.ToString("dd-MM-yyyy")); } //-> /File }
public void SimpleTest() { FixedFileEngine engine = new FixedFileEngine(typeof(CustomersFixed)); Assert.AreEqual(91, Common.ReadTest(engine, @"Good\CustomersFixed.txt").Length); engine.Options.IgnoreFirstLines = 10; Assert.AreEqual(81, Common.ReadTest(engine, @"Good\CustomersFixed.txt").Length); engine.Options.IgnoreLastLines = 6; Assert.AreEqual(75, Common.ReadTest(engine, @"Good\CustomersFixed.txt").Length); Assert.AreEqual(183, engine.Options.RecordLength); }
public void SimpleTest3() { FixedFileEngine engine = new FixedFileEngine(typeof(CustomersFixed2)); Assert.AreEqual(8, FileTest.Good.CustomersFixed.ReadWithEngine(engine).Length); }
public void BadRecordType2() { FixedFileEngine engine = new FixedFileEngine(null); }
public void BadRecordType1() { FixedFileEngine engine = new FixedFileEngine(typeof(CustomersTab)); }
public void SimpleTest3() { FixedFileEngine engine = new FixedFileEngine(typeof(CustomersFixed2)); Assert.AreEqual(8, Common.ReadTest(engine, @"Good\CustomersFixed.txt").Length); }