Beispiel #1
0
 public void Save()
 {
     if (m_UseStars.Count > 0)
     {
         CsvUtil.SaveObjects(m_UseStars, m_ArchiveFilePath);
     }
 }
Beispiel #2
0
    public void TestSaveMulti()
    {
        List <TestObject> objs = new List <TestObject>()
        {
            new TestObject("Hello there", 123, 300.2f, TestObject.Colour.Blue),
            new TestObject("This,has,commas", 42, 12.123f, TestObject.Colour.Purple),
            new TestObject("Semi;colons", 40001, -75.2f, TestObject.Colour.Green),
        };

        using (var stream = new MemoryStream(256))
        {
            using (var w = new StreamWriter(stream))
            {
                CsvUtil.SaveObjects(objs, w);
                w.Flush();

                stream.Seek(0, SeekOrigin.Begin);
                var r        = new StreamReader(stream);
                var content  = r.ReadToEnd();
                var expected = @"StringField,IntField,FloatField,EnumField
                            Hello there,123,300.2,Blue
                            ""This,has,commas"",42,12.123,Purple
                            ""Semi;colons"",40001,-75.2,Green";
            }
        }
    }
Beispiel #3
0
        static void test01()
        {
            System.IO.Directory.SetCurrentDirectory("D:\\Dpan\\workspace\\C#\\ConsoleApp1\\ConsoleApp1\\");
            CsvUtil <Student> csvUtil = new CsvUtil <Student>();
            List <Student>    list    = csvUtil.LoadObjects("student.csv");

            foreach (Student stu in list)
            {
                //Console.Write("id:" + stu.Id + " name :" + stu.Name+"\n" );
            }
            csvUtil.SaveObjects(list, "student2.csv");
        }
Beispiel #4
0
 void _SaveListToAssets(List <MyObject> lst, string filename)
 {
     CsvUtil.SaveObjects <MyObject>(lst, filename);
     Debug.Log("Test SaveListToAssets");
 }