Пример #1
0
        public void Load()
        {
            do
            {
                try
                {
                    _config = ConfigurationManager.OpenMappedExeConfiguration(_map, ConfigurationUserLevel.PerUserRoaming);
                    _group = _config.SectionGroups["libSnesDotNet"];

                    if (_group != null)
                    {
                        _group.Validate();
                    }
                    else
                    {
                        _group = new ConfigurationSectionGroup();
                        _config.SectionGroups.Add("libSnesDotNet", _group);
                    }
                }
                catch
                {
                    var result = System.Windows.MessageBox.Show("Configuration is invalid. Restore defaults instead?", "Error",
                                                                System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Error);
                    if (result == System.Windows.MessageBoxResult.Yes)
                    {
                        _group = null;
                        File.Delete(_map.RoamingUserConfigFilename);
                    }
                    else
                    {
                        return;
                    }
                }
            } while (_group == null);

            if (UI == null) { UI = new UISection(); }
            if (Input == null) { Input = new InputSection(); }
        }