Example #1
0
        public RoamingVisualStudioProfileOptionPersister(IGlobalOptionService globalOptionService, [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
            : base(assertIsForeground: true) // The GetService call requires being on the UI thread or else it will marshal and risk deadlock
        {
            Contract.ThrowIfNull(globalOptionService);

            this._settingManager = (ISettingsManager)serviceProvider.GetService(typeof(SVsSettingsPersistenceManager));
            _globalOptionService = globalOptionService;

            // While the settings persistence service should be available in all SKUs it is possible an ISO shell author has undefined the
            // contributing package. In that case persistence of settings won't work (we don't bother with a backup solution for persistence
            // as the scenario seems exceedingly unlikely), but we shouldn't crash the IDE.
            if (this._settingManager != null)
            {
                ISettingsSubset settingsSubset = this._settingManager.GetSubset("*");
                settingsSubset.SettingChangedAsync += OnSettingChangedAsync;
            }
        }
        public AbstractSettingsManagerOptionSerializer(VisualStudioWorkspaceImpl workspace)
            : base(assertIsForeground: true) // The GetService call requires being on the UI thread or else it will marshal and risk deadlock
        {
            Contract.ThrowIfNull(workspace);

            _storageKeyToOptionMap = new Lazy <ImmutableDictionary <string, IOption> >(CreateStorageKeyToOptionMap, isThreadSafe: true);

            this.Manager   = workspace.GetVsService <SVsSettingsPersistenceManager, ISettingsManager>();
            _optionService = workspace.Services.GetService <IOptionService>();

            // While the settings persistence service should be available in all SKUs it is possible an ISO shell author has undefined the
            // contributing package. In that case persistence of settings won't work (we don't bother with a backup solution for persistence
            // as the scenario seems exceedingly unlikely), but we shouldn't crash the IDE.
            if (this.Manager != null)
            {
                ISettingsSubset settingsSubset = this.Manager.GetSubset(SettingStorageRoot + "*");
                settingsSubset.SettingChangedAsync += OnSettingChangedAsync;
            }
        }