예제 #1
0
        private void OpenFile()
        {
            var dialog = new OpenFileDialog();

            dialog.DefaultExt = ".json";

            dialog.Filter = "Json documents (.json)|*.json";

            var res = dialog.ShowDialog();

            if (res == true)
            {
                var fileName = dialog.FileName;

                try
                {
                    var timeLine = JsonImporter.Import(fileName);

                    Documents.Add(new DocumentVM(fileName, timeLine));
                } catch (JsonException e)
                {
                    MessageBox.Show($"There was errors while parse file: \n {e.Message}");
                }
            }
        }
예제 #2
0
        private void ResetDatabase(JsonImporter jsonImporter)
        {
            using (var context = new CarDealerContext())
            {
                context.Database.EnsureDeleted();
                context.Database.Migrate();
            }

            jsonImporter.Import();
        }
예제 #3
0
        public void ImportToJsonType1()
        {
            ModelExportImport model =
                JsonImporter.Import("json\\name1.json");

            if (model != null)
            {
                if (model.stuffs[0].id == model.stuffs[0].result)
                {
                    ;
                }
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Select your option");
            Console.WriteLine("1: Read from XML");
            Console.WriteLine("2: Read from JSON");
            var key = Console.ReadKey(false);

            IEnumerable <Horse> horses = new List <Horse>();
            IImporter           importer;

            while (key.Key == ConsoleKey.D1 || key.Key == ConsoleKey.D2)
            {
                if (key.Key == ConsoleKey.D1)
                {
                    importer = new XMLImporter();
                    horses   = importer.Import();
                    break;
                }
                else
                {
                    importer = new JsonImporter();
                    horses   = importer.Import();
                    break;
                }
            }

            //Console.WriteLine("Press any key to read from XML file and display horses");

            Console.ReadKey();

            Console.WriteLine("Now printing horses...");

            //Ascending order of horses by price
            horses = horses.OrderBy(h => h.Price);

            Console.WriteLine("-----------------------------------------------");
            Console.WriteLine("Ordering horses by ascending order of their prices.");
            Console.WriteLine("Horse Name | Price");

            foreach (var horse in horses)
            {
                Console.WriteLine(horse.Name + " | " + horse.Price);
            }


            Console.WriteLine("Press any key to end");
            Console.ReadKey();
        }