Ejemplo n.º 1
0
        public async static Task Main(string[] args)
        {
            ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
            CancellationTokenSource cts = new CancellationTokenSource();

            fLog.Info("Started to process the data...");

            IoFactory  factory   = new IoFactory();
            IIoService ioService = factory.GetIoService(true);

            string input = await ioService.ReadFromSourceAsync();

            fLog.Info($"Input file : {input}");

            ITransformationService transformationService = new TransformFileService();
            string output = transformationService.Transform(ioService.GetSourceDocumentType(), ioService.GetDestinationDocumentType(), input);

            ioService = factory.GetIoService(false);

            await ioService.SaveToDestinationAsync(output, cts.Token);             //TODO make write async also - not such usable in this case

            fLog.Info($"Finished the processing with: {output}...");
        }
Ejemplo n.º 2
0
        public void TranformFileJsonXmlTest()
        {
            string to     = ".xml";
            string from   = ".json";
            string source = "{\"Title\":\"Titulek\",\"Text\":\"Tohle je testovaci text v cestine!\"}";

            TransformFileService transformFileService = new TransformFileService();

            Assert.AreEqual("<Document>\r\n  <Title>Titulek</Title>\r\n  <Text>Tohle je testovaci text v cestine!</Text>\r\n</Document>", transformFileService.Transform(from, to, source));
        }
Ejemplo n.º 3
0
        public void TransformFileXmlJsonTest()
        {
            string from = ".xml";
            string to   = ".json";

            XElement xml    = new XElement("Document", new XElement("Title", "Titulek"), new XElement("Text", "Tohle je testovaci text v cestine!"));
            string   source = xml.ToString();

            TransformFileService transformFileService = new TransformFileService();

            Assert.AreEqual("{\"Title\":\"Titulek\",\"Text\":\"Tohle je testovaci text v cestine!\"}", transformFileService.Transform(from, to, source));
        }