コード例 #1
0
        /// <summary>
        ///   Hydrates the properties from the registry asynchronously.
        /// </summary>
        public virtual async Task LoadAsync()
        {
            s_log.Info("Load options from config file");
            OptionsFacade.CurrentOptions = await OptionsFacade.LoadAsync();

            foreach (var property in GetOptionProperties())
            {
                if (typeof(OptionsFacade).GetProperty(property.Name)?.PropertyType != property.PropertyType)
                {
                    continue;
                }

                var facadeProperty = typeof(OptionsFacade).GetProperty(property.Name);
                if (facadeProperty != null)
                {
                    property.SetValue(this, facadeProperty.GetValue(OptionsFacade.CurrentOptions));
                }
            }
        }
コード例 #2
0
        private async Task MigrateOptionsAsync()
        {
            if (!File.Exists(OptionsFacade.DefaultCoreOptionsPath) || !File.Exists(OptionsFacade.DefaultVisualStudioOptionsPath))
            {
                var optionsPage = (OptionsPage)GetDialogPage(typeof(OptionsPage));
                var defaultLicenseHeaderPage = (DefaultLicenseHeaderPage)GetDialogPage(typeof(DefaultLicenseHeaderPage));
                var languagesPage            = (LanguagesPage)GetDialogPage(typeof(LanguagesPage));

                optionsPage.MigrateOptions();
                defaultLicenseHeaderPage.MigrateOptions();
                languagesPage.MigrateOptions();
            }
            else
            {
                OptionsFacade.CurrentOptions = await OptionsFacade.LoadAsync();
            }

            OptionsFacade.CurrentOptions.Version = Version;
            await OptionsFacade.SaveAsync(OptionsFacade.CurrentOptions);
        }