示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
		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);
		}
示例#4
0
		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);
		}
示例#5
0
        /// <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));
        }