Exemplo n.º 1
0
        public void XML(Stream fileStream)
        {
            var stream = new StreamReader(fileStream);

            using (stream)
            {
                using (var parser = new ChoXmlReader(stream))
                {
                    dynamic row;
                    while ((row = parser.Read()) != null)
                    {
                        var paymentDto = new PaymentModel()
                        {
                            Id = row.Id,
                            TransactionDate = Convert.ToDateTime(row.TransactionDate),
                            Amount          = Convert.ToDecimal(row.PaymentDetails.Amount),
                            CurrencyCode    = row.PaymentDetails.CurrencyCode,
                            Status          = row.Status
                        };
                        var payment = Mapper.Map <Payment>(paymentDto);
                        paymentRepository.Insert(payment);
                    }
                }
            }
        }
Exemplo n.º 2
0
        static void QuickTestWithXmlNS()
        {
            using (var stream = new MemoryStream())
                using (var reader = new StreamReader(stream))
                    using (var writer = new StreamWriter(stream))
                        using (var parser = new ChoXmlReader(reader).WithXPath("/cont:contacts/cont:contact/cont:contact1").WithXmlNamespace("cont", "www.tutorialspoint.com/profile").WithField("name", "cont:name"))
                        {
                            writer.WriteLine(@"<cont:contacts xmlns:cont=""www.tutorialspoint.com/profile"">
                <cont:contact >
                    <cont:contact1 >
                       <cont:name>Tanmay Patilx</cont:name>
                       <cont:company>TutorialsPoint</cont:company>
                       <cont:phone> (011) 123 - 4567 </cont:phone>
                    </cont:contact1> 
                    <cont:contact1 >
                       <cont:name>Tanmay Patilx1</cont:name>
                       <cont:company>TutorialsPoint</cont:company>
                       <cont:phone> (011) 123 - 4567 </cont:phone>
                    </cont:contact1> 
                   <cont:name>Tanmay Patil</cont:name>
                   <cont:company>TutorialsPoint</cont:company>
                   <cont:phone> (011) 123 - 4567 </cont:phone>
                </cont:contact> 
                <cont:contact >
                     <cont:contact1 >
                       <cont:name>Tanmay Patily</cont:name>
                       <cont:company>TutorialsPoint</cont:company>
                       <cont:phone> (011) 123 - 4567 </cont:phone>
                    </cont:contact1> 
                      <cont:contact1 >
                       <cont:name>Tanmay Patily1</cont:name>
                       <cont:company>TutorialsPoint</cont:company>
                       <cont:phone> (011) 123 - 4567 </cont:phone>
                    </cont:contact1> 
                 <cont:name>Tanmay Patil1</cont:name>
                   <cont:company>TutorialsPoint1</cont:company>
                   <cont:phone> (011) 123 - 45671 </cont:phone>
                </cont:contact> 
                </cont:contacts>
                ");

                            writer.Flush();
                            stream.Position = 0;

                            object rec;
                            while ((rec = parser.Read()) != null)
                            {
                                Console.WriteLine(rec.ToStringEx());
                            }
                        }
        }
Exemplo n.º 3
0
        static void CodeFirstTest()
        {
            using (var stream = new MemoryStream())
                using (var reader = new StreamReader(stream))
                    using (var writer = new StreamWriter(stream))
                        using (var parser = new ChoXmlReader <EmployeeRecSimple>(reader))
                        {
                            writer.WriteLine(EmpXml);

                            writer.Flush();
                            stream.Position = 0;

                            object rec;
                            while ((rec = parser.Read()) != null)
                            {
                                Console.WriteLine(rec.ToStringEx());
                            }
                        }
        }
Exemplo n.º 4
0
        static void ConfigFirstDynamicTest()
        {
            ChoXmlRecordConfiguration config = new ChoXmlRecordConfiguration();

            config.XmlRecordFieldConfigurations.Add(new ChoXmlRecordFieldConfiguration("Id"));
            config.XmlRecordFieldConfigurations.Add(new ChoXmlRecordFieldConfiguration("Name"));

            using (var stream = new MemoryStream())
                using (var reader = new StreamReader(stream))
                    using (var writer = new StreamWriter(stream))
                        using (var parser = new ChoXmlReader(reader, config))
                        {
                            writer.WriteLine(EmpXml);

                            writer.Flush();
                            stream.Position = 0;

                            object rec;
                            while ((rec = parser.Read()) != null)
                            {
                                Console.WriteLine(rec.ToStringEx());
                            }
                        }
        }