Esempio n. 1
0
        public static void Main()
        {
            using (var file = File.Open("Config.json", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read))
            {
                /* Create an instance of the emulator machine */
                Machine machine = new Machine();

                /* Load configuration */
                try
                {
                    machine.ImportConfig(JsonConvert.DeserializeObject<ExpandoObject>(new StreamReader(file).ReadToEnd()));
                }
                catch
                {
                    logger.Trace("Config.json was not valid, skipped configuration merge");
                }
                finally
                {
                    /* Clear the configuration file */
                    file.SetLength(0);
                    file.Flush();
                }

                /* WPF Start */
                App app = new App();
                app.InitializeComponent();
                app.Run();

                /* Save configuration */
                var writer = new StreamWriter(file);
                writer.Write(JsonConvert.SerializeObject(machine.ExportConfig(), Formatting.Indented));
                writer.Flush();

                machine.Dispose();
            }
        }