예제 #1
0
        static void Main(string[] args)
        {
            SheduleClass shed = new SheduleClass("Task1", 1);

            shed_mas.Add(shed);
            shed.name     = "Task2";
            shed.priority = 3;
            shed_mas.Add(shed);
            shed.name     = "Task3";
            shed.priority = 2;
            shed_mas.Add(shed);
            shed.name     = "Task4";
            shed.priority = 1;
            shed_mas.Add(shed);
            shed.name     = "Task9";
            shed.priority = 3;
            shed_mas.Add(shed);

            string json = JsonConvert.SerializeObject(shed_mas);

            //Console.WriteLine(json);
            shed_mas.SaveToFile(@"d:\fb.txt");

            SheduleMasClass dshed_mas = new SheduleMasClass();

            dshed_mas.LoadFromFile(@"d:\fb.txt");
            Console.WriteLine(dshed_mas);


            Console.ReadKey();
        }
예제 #2
0
        public void LoadFromFile(string FileName)
        {
            string json = "";

            using (StreamReader sr = new StreamReader(FileName))
            {
                json = sr.ReadToEnd();
            }

            SheduleMasClass dshed_mas = new SheduleMasClass();
            //Console.WriteLine(json);
            List <SheduleClass> ldshed_mas = new List <SheduleClass>();

            ldshed_mas = JsonConvert.DeserializeObject <List <SheduleClass> >(json);
            //Console.WriteLine(ldshed_mas[1]);
            shed_mas.Clear();
            for (int i = 0; i < ldshed_mas.Count; i++)
            {
                SheduleClass shed = new SheduleClass();
                shed = ldshed_mas[i];
                shed_mas.Add(shed);
            }
        }