Esempio n. 1
0
        public static void IgnoreSolution(bool ignore)
        {
            WritableSettingsStore wstore = _settings.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!wstore.CollectionExists(Constants.VSIX_NAME))
            {
                wstore.CreateCollection(Constants.VSIX_NAME);
            }

            string solution = VSPackage.GetSolution();

            if (string.IsNullOrEmpty(solution))
            {
                return;
            }

            string property = GetPropertyName(solution);

            if (ignore)
            {
                wstore.SetInt32(Constants.VSIX_NAME, property, 1);
            }
            else
            {
                wstore.DeleteProperty(Constants.VSIX_NAME, property);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Deletes property from settings store if it exists within specified collection
 /// </summary>
 /// <param name="store">Extending class</param>
 /// <param name="collectionPath">Path of the collection of the property</param>
 /// <param name="propertyName">Name of the property</param>
 public static void DeletePropertyIfExists(this WritableSettingsStore store, string collectionPath, string propertyName)
 {
     if (store.PropertyExists(collectionPath, propertyName))
     {
         store.DeleteProperty(collectionPath, propertyName);
     }
 }
        internal VersionProvider(IServiceProvider serviceProvider)
        {
            var settingsManager = new ShellSettingsManager(serviceProvider);
            _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!_settingsStore.CollectionExists(CollectionName))
                _settingsStore.CreateCollection(CollectionName);

            if (_settingsStore.PropertyExists(CollectionName, OldVersionPropertyName))
                _settingsStore.DeleteProperty(CollectionName, OldVersionPropertyName);
        }
Esempio n. 4
0
 public static void RevertTemplateToDefault(MockFramework mockFramework)
 {
     foreach (TemplateType templateType in Enum.GetValues(typeof(TemplateType)))
     {
         string templateSettingKey = GetTemplateSettingsKey(mockFramework, templateType);
         if (Store.PropertyExists(CollectionPath, templateSettingKey))
         {
             Store.DeleteProperty(CollectionPath, templateSettingKey);
         }
     }
 }
Esempio n. 5
0
        private static void RemoveExtensionFromPendingDeletions(WritableSettingsStore settingsStore, IExtensionHeader extensionHeader)
        {
            const string PendingDeletionsCollectionPath = ExtensionManagerCollectionPath + @"\PendingDeletions";
            var          vsixToDeleteProperty           = $"{extensionHeader.Identifier},{extensionHeader.Version}";

            if (settingsStore.CollectionExists(PendingDeletionsCollectionPath) &&
                settingsStore.PropertyExists(PendingDeletionsCollectionPath, vsixToDeleteProperty))
            {
                settingsStore.DeleteProperty(PendingDeletionsCollectionPath, vsixToDeleteProperty);
            }
        }
Esempio n. 6
0
        private void OK_OnClick(object sender, RoutedEventArgs e)
        {
            SettingsManager       settingsManager            = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider);
            WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            configurationSettingsStore.CreateCollection(LogcatOutputToolWindowControl.StoreCategoryName);
            if (AdbPathText.Text.Length == 0)
            {
                configurationSettingsStore.DeleteProperty(LogcatOutputToolWindowControl.StoreCategoryName,
                                                          LogcatOutputToolWindowControl.StorePropertyAdbPathName);
            }
            else
            {
                configurationSettingsStore.SetString(LogcatOutputToolWindowControl.StoreCategoryName,
                                                     LogcatOutputToolWindowControl.StorePropertyAdbPathName, AdbPathText.Text);
            }
            uint log_limit = System.Convert.ToUInt32(LogLimitText.Text);

            configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName,
                                                 LogcatOutputToolWindowControl.StorePropertyLogsLimitName, log_limit);
            ToolCtrl.LogLimitCount  = log_limit;
            ToolCtrl.adb.AdbExePath = AdbPathText.Text;

            uint level_width = Convert.ToUInt32(LevelWidthText.Text);

            configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName,
                                                 LogcatOutputToolWindowControl.StorePropertyLevelWidthName, level_width);
            uint time_width = Convert.ToUInt32(TimeWidthText.Text);

            configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName,
                                                 LogcatOutputToolWindowControl.StorePropertyTimeWidthName, time_width);
            uint pid_width = Convert.ToUInt32(PIDWidthText.Text);

            configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName,
                                                 LogcatOutputToolWindowControl.StorePropertyPidWidthName, pid_width);
            uint tag_width = Convert.ToUInt32(TagWidthText.Text);

            configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName,
                                                 LogcatOutputToolWindowControl.StorePropertyTagWidthName, tag_width);
            uint text_width = Convert.ToUInt32(TextWidthText.Text);

            configurationSettingsStore.SetUInt32(LogcatOutputToolWindowControl.StoreCategoryName,
                                                 LogcatOutputToolWindowControl.StorePropertyTextWidthName, text_width);

            ToolCtrl.ColumnWidth[0] = level_width;
            ToolCtrl.ColumnWidth[1] = time_width;
            ToolCtrl.ColumnWidth[2] = pid_width;
            ToolCtrl.ColumnWidth[3] = tag_width;
            ToolCtrl.ColumnWidth[4] = text_width;
            ToolCtrl.RefreshColumnsWidth();

            ToClose?.Invoke();
        }
Esempio n. 7
0
        internal VersionProvider(IServiceProvider serviceProvider)
        {
            var settingsManager = new ShellSettingsManager(serviceProvider);

            _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!_settingsStore.CollectionExists(CollectionName))
            {
                _settingsStore.CreateCollection(CollectionName);
            }

            if (_settingsStore.PropertyExists(CollectionName, OldVersionPropertyName))
            {
                _settingsStore.DeleteProperty(CollectionName, OldVersionPropertyName);
            }
        }
Esempio n. 8
0
        public void SaveString(string name, string category, string value)
        {
            var path = GetCollectionPath(category);

            if (value == null)
            {
                if (_settingsStore.CollectionExists(path))
                {
                    _settingsStore.DeleteProperty(path, name);
                }
            }
            else
            {
                if (!_settingsStore.CollectionExists(path))
                {
                    _settingsStore.CreateCollection(path);
                }
                _settingsStore.SetString(path, name, value);
            }
        }
        public static void SetValue(this WritableSettingsStore store, string collectionPath, string propertyName, object value)
        {
            switch (value)
            {
            case null: store.DeleteProperty(collectionPath, propertyName);
                break;

            case string s: store.SetString(collectionPath, propertyName, s);
                break;

            case long l: store.SetInt64(collectionPath, propertyName, l);
                break;

            case int i: store.SetInt32(collectionPath, propertyName, i);
                break;

            case bool b: store.SetBoolean(collectionPath, propertyName, b);
                break;
            }
        }
        public Task <SettingsModel> GetSettingsAsync()
        {
            return(Task.Run(() =>
            {
                try
                {
                    // migrate classic storage to newer TeamProjectCollection-based storage
                    if (_writableSettingsStore.PropertyExists(CollectionPath, ClassicPropertyName))
                    {
                        var settingsString = _writableSettingsStore.GetString(CollectionPath, ClassicPropertyName);
                        SaveSetingsString(settingsString);
                        _writableSettingsStore.DeleteProperty(CollectionPath, ClassicPropertyName);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Fail(ex.Message);
                }

                return GetSettingsModel();
            }));
        }
Esempio n. 11
0
        public static void IgnoreFileType(IEnumerable <string> fileTypes, bool ignore)
        {
            WritableSettingsStore wstore = _settings.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!wstore.CollectionExists(Constants.VSIX_NAME))
            {
                wstore.CreateCollection(Constants.VSIX_NAME);
            }

            foreach (string fileType in fileTypes)
            {
                string property = fileType.ToLowerInvariant();

                if (ignore)
                {
                    wstore.SetInt32(Constants.VSIX_NAME, property, 1);
                }
                else
                {
                    wstore.DeleteProperty(Constants.VSIX_NAME, property);
                }
            }
        }
Esempio n. 12
0
        protected bool DeleteProperty(string settingsRoot, string property)
        {
            WritableSettingsStore userSettingsStore = GetWritableSettingsStore(settingsRoot);

            return(userSettingsStore.DeleteProperty(settingsRoot, property));
        }
Esempio n. 13
0
        static StaticBoilerplateSettings()
        {
            SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);

            Store = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            Store.CreateCollection(CollectionPath);

            // Setting upgrade if needed
            if (Store.PropertyExists(CollectionPath, VersionKey))
            {
                int storedVersion = Store.GetInt32(CollectionPath, VersionKey);
                if (storedVersion < LatestVersion)
                {
                    SetVersionToLatest();
                }
            }
            else
            {
                if (Store.PropertyExists(CollectionPath, TestProjectsKey))
                {
                    // We are upgrading from an old version (v0), as we didn't have version tracked, but had a test projects dictionary

                    var mockFrameworks = new List <string> {
                        "Moq", "AutoMoq", "SimpleStubs", "NSubstitute"
                    };
                    var templateTypes = new List <TemplateType> {
                        TemplateType.File, TemplateType.MockFieldDeclaration, TemplateType.MockFieldInitialization, TemplateType.MockObjectReference
                    };
                    foreach (string mockFrameworkName in mockFrameworks)
                    {
                        MockFramework mockFramework = MockFrameworks.Get(mockFrameworkName);

                        foreach (TemplateType templateType in templateTypes)
                        {
                            string templateKey = $"Template_{mockFrameworkName}_{templateType}";

                            if (Store.PropertyExists(CollectionPath, templateKey))
                            {
                                string oldTemplate = Store.GetString(CollectionPath, templateKey);

                                CreateEntryForTestFramework(oldTemplate, templateType, TestFrameworks.Get("VisualStudio"), mockFramework);
                                CreateEntryForTestFramework(oldTemplate, templateType, TestFrameworks.Get("NUnit"), mockFramework);

                                Store.DeleteProperty(CollectionPath, templateKey);
                            }
                        }
                    }
                }

                SetVersionToLatest();
            }

            if (Store.PropertyExists(CollectionPath, TestProjectsKey))
            {
                string dictionaryString = Store.GetString(CollectionPath, TestProjectsKey);

                if (string.IsNullOrEmpty(dictionaryString))
                {
                    TestProjectsDictionary = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                }
                else
                {
                    TestProjectsDictionary = new Dictionary <string, string>(JsonConvert.DeserializeObject <Dictionary <string, string> >(dictionaryString), StringComparer.OrdinalIgnoreCase);
                }
            }
            else
            {
                TestProjectsDictionary = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            }
        }
Esempio n. 14
0
 public static void DeletePropertyFromUserSettings(string propertyName)
 {
     _userSettingsStore.DeleteProperty(REGISTRY_FOLDER_NAME, propertyName);
 }
Esempio n. 15
0
 public bool ClearData(string propertyName)
 {
     return(_writableSettingsStore.DeleteProperty(tasCollectionPath, propertyName));
 }
Esempio n. 16
0
 public void DeleteProperty(string collectionPath, string propertyName)
 {
     store.DeleteProperty(collectionPath, propertyName);
 }
Esempio n. 17
0
 public static void DeletePropertyFromUserSettings(string propertyName)
 {
     _userSettingsStore.DeleteProperty("External Tools", propertyName);
 }