public void AsyncCsvToDelimited() { FileTransformEngine link = new FileTransformEngine(typeof(FromClass), typeof(ToClass2)); link.TransformFileAsync(Common.TestPath("Good\\Transform1.txt"), Common.TestPath("Good\\transformout.txt")); FileHelperEngine engine = new FileHelperEngine(typeof(ToClass2)); ToClass2[] res = (ToClass2[])engine.ReadFile(Common.TestPath("Good\\transformout.txt")); if (File.Exists(Common.TestPath("Good\\transformout.txt"))) { File.Delete(Common.TestPath("Good\\transformout.txt")); } Assert.AreEqual(6, res.Length); }
public void AsyncCsvToDelimited2() { FileTransformEngine link = new FileTransformEngine(typeof(FromClass), typeof(ToClass2)); link.TransformFileAsync(Common.TestPath("Good\\Transform2.txt"), Common.TestPath("Good\\transformout.txt")); FileHelperEngine engine = new FileHelperEngine(typeof(ToClass2)); ToClass2[] res = (ToClass2[])engine.ReadFile(Common.TestPath("Good\\transformout.txt")); if (File.Exists(Common.TestPath("Good\\transformout.txt"))) { File.Delete(Common.TestPath("Good\\transformout.txt")); } Assert.AreEqual(@"c:\Prueba1\anda ?", res[0].CompanyName); Assert.AreEqual("\"D:\\Glossaries\\O12\"", res[1].CompanyName); Assert.AreEqual(@"\\s\\", res[2].CompanyName); }
public void AsyncCsvToDelimited() { FileTransformEngine link = new FileTransformEngine(typeof(FromClass), typeof(ToClass2)); link.TransformFileAsync(Common.TestPath("Good\\Transform1.txt"), Common.TestPath("Good\\transformout.txt")); FileHelperEngine engine = new FileHelperEngine(typeof(ToClass2)); ToClass2[] res = (ToClass2[]) engine.ReadFile(Common.TestPath("Good\\transformout.txt")); if (File.Exists(Common.TestPath("Good\\transformout.txt"))) File.Delete(Common.TestPath("Good\\transformout.txt")); Assert.AreEqual(6, res.Length); }
public void AsyncCsvToDelimited2() { FileTransformEngine link = new FileTransformEngine(typeof(FromClass), typeof(ToClass2)); link.TransformFileAsync(Common.TestPath("Good\\Transform2.txt"), Common.TestPath("Good\\transformout.txt")); FileHelperEngine engine = new FileHelperEngine(typeof(ToClass2)); ToClass2[] res = (ToClass2[]) engine.ReadFile(Common.TestPath("Good\\transformout.txt")); if (File.Exists(Common.TestPath("Good\\transformout.txt"))) File.Delete(Common.TestPath("Good\\transformout.txt")); Assert.AreEqual(@"c:\Prueba1\anda ?", res[0].CompanyName); Assert.AreEqual("\"D:\\Glossaries\\O12\"", res[1].CompanyName); Assert.AreEqual(@"\\s\\", res[2].CompanyName); }
/// <summary> /// <b>Faster way</b> to Transform the records of type sourceType in the sourceFile in records of type destType and write them to the destFile. /// </summary> /// <param name="sourceType">The Type of the records in the source File.</param> /// <param name="destType">The Type of the records in the dest File.</param> /// <param name="sourceFile">The file with records to be transformed</param> /// <param name="destFile">The destination file with the transformed records</param> /// <returns>The number of transformed records</returns> public static int TransformFileAsync(string sourceFile, Type sourceType, string destFile, Type destType) { var engine = new FileTransformEngine(sourceType, destType); return(engine.TransformFileAsync(sourceFile, destFile)); }