Exemple #1
0
        public static IVsSettingsManager Create()
        {
            IVsSettingsManager sm = Substitute.For <IVsSettingsManager>();

            string s;

            sm.GetApplicationDataFolder(Arg.Any <uint>(), out s).ReturnsForAnyArgs(x => {
                x[1] = Path.GetTempPath();
                return(VSConstants.S_OK);
            });

            IVsSettingsStore store;

            sm.GetReadOnlySettingsStore(Arg.Any <uint>(), out store).ReturnsForAnyArgs(x => {
                x[1] = VsSettingsStoreMock.Create();
                return(VSConstants.S_OK);
            });

            IVsWritableSettingsStore writable;

            sm.GetWritableSettingsStore(Arg.Any <uint>(), out writable).ReturnsForAnyArgs(x => {
                x[1] = VsSettingsStoreMock.Create();
                return(VSConstants.S_OK);
            });

            return(sm);
        }
Exemple #2
0
        public bool SaveOption(IEditorOptions options, string optionName)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            while (true)
            {
                if (options.IsOptionDefined(optionName, true))
                {
                    break;
                }

                options = options.Parent;
                if (options == null)
                {
                    return(false);       //Unable to save option.
                }
            }

            IVsSettingsManager       manager = this.SettingsManagerService;
            IVsWritableSettingsStore store;

            Marshal.ThrowExceptionForHR(manager.GetWritableSettingsStore((uint)__VsSettingsScope.SettingsScope_UserSettings, out store));

            string result = options.GetOptionValue(optionName).ToString();

            Marshal.ThrowExceptionForHR(store.SetString("Text Editor", optionName, result));

            return(true);
        }
Exemple #3
0
        public IWritableSettingsStore GetWritableSettingsStore()
        {
            IVsWritableSettingsStore settingsStore;

            int hr = _settingsManager.GetWritableSettingsStore((uint)__VsSettingsScope.SettingsScope_UserSettings, out settingsStore);

            if (ErrorHandler.Succeeded(hr) && settingsStore != null)
            {
                return(new WritableSettingsStoreWrapper(settingsStore));
            }

            return(null);
        }
Exemple #4
0
 public SettingsStore(IVsSettingsManager manager, IEditorOptions options)
 {
     _options = options;
     manager.GetWritableSettingsStore((uint)__VsSettingsScope.SettingsScope_UserSettings, out _store);
 }