Пример #1
0
        public async override void Execute()
        {
            var dialog = new OpenFileDialog
            {
                AddExtension    = true,
                CheckFileExists = true
            };

            string path = viewModel.ConfigurationPath;

            if (String.IsNullOrEmpty(path))
            {
                dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
            }
            else
            {
                dialog.FileName         = Path.GetFileNameWithoutExtension(path);
                dialog.DefaultExt       = Path.GetExtension(path);
                dialog.InitialDirectory = Path.GetDirectoryName(path);
                dialog.Filter           = "Configuration File (*.json)|*.json";
            }

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                path = dialog.FileName;

                ISettingsService target         = settingsFactory.CreateForFile(path);
                ISettings        targetSettings = await target.LoadAsync();

                mapper.Map(targetSettings, viewModel);
            }
        }
Пример #2
0
        protected override void Execute()
        {
            Properties.Configuration.Default.Path = viewModel.ConfigurationPath;
            Properties.Configuration.Default.Save();

            mapper.Map(viewModel, settings);

            settingsService.SaveAsync(settings);
            EventManager.RaiseConfigurationSaved(viewModel);
        }