示例#1
0
        private void cmdRun_Click(object sender, EventArgs e)
        {
            CustomersVerticalBar[] customers = (CustomersVerticalBar[])grid1.SelectedObject;
            //
            DelimitedFileEngine engine = new DelimitedFileEngine(typeof(CustomersVerticalBar));

            txtOut1.Text = engine.WriteString(customers);

            engine.Options.Delimiter = ";";
            txtOut2.Text             = engine.WriteString(customers);

            engine.Options.Delimiter = "\t";
            txtOut3.Text             = engine.WriteString(customers);
        }
示例#2
0
        public void ArrayWriteFloatFields3()
        {
            var dataToExport = new List <ArrayModel1>();

            dataToExport.Add(new ArrayModel1()
            {
                Id = 1, Name = "name1", Weighting = new float[] { 10.2f, 30.5f, 11f }
            });

            var engine = new DelimitedFileEngine <ArrayModel1>();
            var res    = engine.WriteString(dataToExport);

            Assert.AreEqual("1,name1,10.2,30.5,11" + Environment.NewLine, res);
        }
示例#3
0
 public void ArrayWriteMinError1()
 {
     Assert.Throws <InvalidOperationException>(
         () => {
         var engine = new DelimitedFileEngine <ArrayModel2To4>();
         engine.WriteString(new[] {
             new ArrayModel2To4()
             {
                 Id        = 1,
                 Name      = "name1",
                 Weighting = new float[] { 10.2f }
             }
         });
     });
 }
示例#4
0
        public void ArrayWriteFloatFieldsNullable()
        {
            var dataToExport = new List <ArrayModelNullable>();

            dataToExport.Add(new ArrayModelNullable()
            {
                Id = 1, Name = "name1", Weighting = new float?[] { }
            });

            var engine = new DelimitedFileEngine <ArrayModelNullable>();
            var res    = engine.WriteString(dataToExport);

            Assert.AreEqual("1,name1," + Environment.NewLine, res);

            var vals = engine.ReadString(res);

            vals.Length.AssertEqualTo(1);
            vals[0].Weighting.Length.AssertEqualTo(0);
        }
示例#5
0
 public void ArrayWriteMinErrorNull()
 {
     Assert.Throws<InvalidOperationException>(
         () => {
             var engine = new DelimitedFileEngine<ArrayModel2To4>();
             var res =
                 engine.WriteString(new[] {
                     new ArrayModel2To4() {
                         Id = 1,
                         Name = "name1",
                         Weighting = null
                     }
                 });
         });
 }
示例#6
0
 public void ArrayWriteMaxError5()
 {
     Assert.Throws<InvalidOperationException>(
         () => {
             var engine = new DelimitedFileEngine<ArrayModel2To4>();
             var res =
                 engine.WriteString(new[] {
                     new ArrayModel2To4() {
                         Id = 1,
                         Name = "name1",
                         Weighting = new float[] {10.2f, 1, 2, 3, 4}
                     }
                 });
         });
 }
示例#7
0
        public void ArrayWriteFloatFieldsNullable()
        {
            var dataToExport = new List<ArrayModelNullable>();
            dataToExport.Add(new ArrayModelNullable() {
                Id = 1,
                Name = "name1",
                Weighting = new float?[] {}
            });

            var engine = new DelimitedFileEngine<ArrayModelNullable>();
            var res = engine.WriteString(dataToExport);

            Assert.AreEqual("1,name1," + Environment.NewLine, res);

            var vals = engine.ReadString(res);
            vals.Length.AssertEqualTo(1);
            vals[0].Weighting.Length.AssertEqualTo(0);
        }
示例#8
0
        public void ArrayWriteFloatFields3()
        {
            var dataToExport = new List<ArrayModel1>();
            dataToExport.Add(new ArrayModel1() {
                Id = 1,
                Name = "name1",
                Weighting = new float[] {10.2f, 30.5f, 11f}
            });

            var engine = new DelimitedFileEngine<ArrayModel1>();
            var res = engine.WriteString(dataToExport);

            Assert.AreEqual("1,name1,10.2,30.5,11" + Environment.NewLine, res);
        }