public void LoadFilterStoreData() { SettingsManager settingsManager = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider); WritableSettingsStore settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (settingsStore.CollectionExists(StoreFilterCollectionName)) { int count = settingsStore.GetSubCollectionCount(StoreFilterCollectionName); IEnumerable <string> filter_name_list = settingsStore.GetSubCollectionNames(LogcatOutputToolWindowControl.StoreFilterCollectionName); if (filter_name_list == null) { return; } foreach (string name in filter_name_list) { string filter_sub_collection = StoreFilterCollectionName + "\\" + name; string tag = settingsStore.GetString(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterTagName, ""); int pid = settingsStore.GetInt32(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterPidName, 0); string msg = settingsStore.GetString(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterMsgName, ""); string pkg = settingsStore.GetString(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterPackageName, ""); int level = settingsStore.GetInt32(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterLevelName, 0); AddFilterItem(name, tag, pid, msg, pkg, (LogcatOutputToolWindowControl.LogcatItem.Level)level, false); } } }
public static void Load() { ResourcesFolderName = settings.GetString(collectionName, nameof(ResourcesFolderName)); ResourcesManagerName = settings.GetString(collectionName, nameof(ResourcesManagerName)); UseStaticResourceXAML = settings.GetBoolean(collectionName, nameof(UseStaticResourceXAML)); SetLocaleOnStartup = settings.GetBoolean(collectionName, nameof(SetLocaleOnStartup)); }
private static void LoadSettingsFromStore(ISettings settings) { var properties = GetProperties(settings); foreach (var prop in properties) { if (store.PropertyExists(settings.Key, prop.Name)) { switch (prop.GetValue(settings)) { case bool b: prop.SetValue(settings, store.GetBoolean(settings.Key, prop.Name)); break; case int i: prop.SetValue(settings, store.GetInt32(settings.Key, prop.Name)); break; case double d when double.TryParse(store.GetString(settings.Key, prop.Name), out double value): prop.SetValue(settings, value); break; case string s: prop.SetValue(settings, store.GetString(settings.Key, prop.Name)); break; } } } }
public Settings(IServiceProvider provider) { SettingsManager settingsManager = new ShellSettingsManager(provider); _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!_settingsStore.CollectionExists("DebugAttachManagerProcesses")) { return; } IEnumerable <string> services = _settingsStore.GetSubCollectionNames("DebugAttachManagerProcesses"); foreach (var s in services) { var p = new StoredProcessInfo { ProcessName = _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "ProcessName"), Title = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "Title") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "Title") : null, RemoteServerName = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemoteServerName") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "RemoteServerName") : null, RemotePortNumber = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") ? _settingsStore.GetInt64("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") : (long?)null, Selected = _settingsStore.GetBoolean("DebugAttachManagerProcesses\\" + s, "Selected"), DebugMode = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "DebugMode") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "DebugMode") : null }; Processes.Add(p.Hash, p); } if (_settingsStore.PropertyExists("DebugAttachManagerProcesses", "RemoteServer")) { RemoteServer = _settingsStore.GetString("DebugAttachManagerProcesses", "RemoteServer"); } }
private void UpdateSettings() { string configVersion = null; if (_settingsStore.PropertyExists(CollectionPath, SettingsVersionPropertyName)) { configVersion = _settingsStore.GetString(CollectionPath, SettingsVersionPropertyName); } if (configVersion == null) { try { var connections = new List <ConnectionDetail>(); var deprecatedConnectionsXml = _settingsStore.GetString(CollectionPath, ConnectionsPropertyName); var deprecatedConnections = (List <McTools.Xrm.Connection.Deprecated.ConnectionDetail>)XmlSerializerHelper.Deserialize(deprecatedConnectionsXml, typeof(List <McTools.Xrm.Connection.Deprecated.ConnectionDetail>)); foreach (var connection in deprecatedConnections) { connections.Add(UpdateConnection(connection)); } var connectionsXml = XmlSerializerHelper.Serialize(connections); _settingsStore.SetString(CollectionPath, ConnectionsPropertyName, connectionsXml); _settingsStore.SetString(CollectionPath, SettingsVersionPropertyName, CurrentConfigurationVersion); } catch (Exception ex) { Logger.Write("Failed to convert connections: " + ex.Message); } } }
private object Get(string key, Type targetType = null, object defaultValue = null, SerializationMode serializationMode = SerializationMode.Xml) { try { if (targetType == null) { targetType = ConvertSettingsType(Check.TryCatch <SettingsType, Exception>(() => settingsStore.GetPropertyType(collectionPath, key))); } object result = null; if (targetType.IsEnum) { targetType = typeof(int); } if (targetType == typeof(bool)) { result = settingsStore.GetBoolean(collectionPath, key, Convert.ToBoolean(defaultValue)); } else if (targetType == typeof(string)) { result = settingsStore.GetString(collectionPath, key, defaultValue as string); } else if (targetType == typeof(int)) { result = settingsStore.GetInt32(collectionPath, key, Convert.ToInt32(defaultValue)); } else { if (settingsStore.PropertyExists(collectionPath, key)) { if (serializationMode == SerializationMode.Xml) { string xmlContent = settingsStore.GetString(collectionPath, key); var serializer = new XmlSerializer(targetType); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xmlContent)); var res = serializer.Deserialize(ms); return(res); } else { var ms = settingsStore.GetMemoryStream(collectionPath, key); if (ms != null) { var serializer = new BinaryFormatter(); result = serializer.Deserialize(ms); } } } } return(result ?? defaultValue); } catch (Exception) { return(defaultValue); } }
private T GetEnum <T>(string settingName, T defaultValue) { if (!_userSettingsStore.PropertyExists(SettingsPropName, settingName)) { return(defaultValue); } var setting = _userSettingsStore.GetString(SettingsPropName, settingName); var rval = (T)Enum.Parse(typeof(T), setting); return(rval); }
public static void LoadCurrent() { try { if (!settingsStore.CollectionExists(COLLECTION_PATH)) { return; } if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.Font))) { CurrentSettings.Font = settingsStore.GetString(COLLECTION_PATH, nameof(FontSettings.Font)); } if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.Size))) { var str = settingsStore.GetString(COLLECTION_PATH, nameof(FontSettings.Size)); double size; double.TryParse(str, out size); CurrentSettings.Size = size; } if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.Italic))) { CurrentSettings.Italic = settingsStore.GetBoolean(COLLECTION_PATH, nameof(FontSettings.Italic)); } if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.Opacity))) { var str = settingsStore.GetString(COLLECTION_PATH, nameof(FontSettings.Opacity)); double opacity; double.TryParse(str, out opacity); CurrentSettings.Opacity = opacity; } if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.HighlightKeywordsOnly))) { CurrentSettings.HighlightKeywordsOnly = settingsStore.GetBoolean(COLLECTION_PATH, nameof(FontSettings.HighlightKeywordsOnly)); } if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.UnderlineImportantComments))) { CurrentSettings.UnderlineImportantComments = settingsStore.GetBoolean(COLLECTION_PATH, nameof(FontSettings.UnderlineImportantComments)); } } catch (Exception ex) { Debug.Fail(ex.Message); } }
private void LoadSettings() { try { _indentSize = _writableSettingsStore.GetInt32(CollectionPath, IndentSizeName, _indentSize); _compilerPath = _writableSettingsStore.GetString(CollectionPath, CompilerPathName, _compilerPath); _srcPath = _writableSettingsStore.GetString(CollectionPath, SrcPathName, _srcPath); } catch (Exception ex) { Debug.Fail(ex.Message); } }
public Settings(IServiceProvider provider) { SettingsManager settingsManager = new ShellSettingsManager(provider); _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!_settingsStore.CollectionExists("DebugAttachManagerProcesses")) { return; } IEnumerable <string> services = _settingsStore.GetSubCollectionNames("DebugAttachManagerProcesses"); foreach (var s in services) { var p = new StoredProcessInfo { ProcessName = _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "ProcessName"), Title = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "Title") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "Title") : null, RemoteServerName = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemoteServerName") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "RemoteServerName") : null, RemotePortNumber = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") ? _settingsStore.GetInt64("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") : (long?)null, Selected = _settingsStore.GetBoolean("DebugAttachManagerProcesses\\" + s, "Selected"), DebugMode = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "DebugMode") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "DebugMode") : null }; Processes.Add(p.Hash, p); } if (_settingsStore.PropertyExists("DebugAttachManagerProcesses", "RemoteServer")) { RemoteServer = _settingsStore.GetString("DebugAttachManagerProcesses", "RemoteServer"); } for (int i = 0; i < Constants.NUMBER_OF_OPTIONAL_COLUMNS; i++) { string columnName = $"Column{i}"; if (_settingsStore.PropertyExists("DebugAttachManagerProcesses", columnName)) { ProcessesColumns[i] = _settingsStore.GetBoolean("DebugAttachManagerProcesses", columnName); } else { if (i == 0) { // This is a hack, so we display PID by default ProcessesColumns[i] = true; } } } }
public static void LoadSettings(ISettings settings) { try { if (store.CollectionExists(settings.Key) != true) { return; } var type = settings.GetType(); foreach (var prop in type.GetProperties().Where(p => Attribute.IsDefined(p, typeof(SettingAttribute)))) { if (prop.PropertyType == typeof(bool)) { if (store.PropertyExists(settings.Key, prop.Name)) { prop.SetValue(settings, store.GetBoolean(settings.Key, prop.Name)); } } else if (prop.PropertyType == typeof(int)) { if (store.PropertyExists(settings.Key, prop.Name)) { prop.SetValue(settings, store.GetInt32(settings.Key, prop.Name)); } } else if (prop.PropertyType == typeof(double)) { if (store.PropertyExists(settings.Key, prop.Name)) { double.TryParse(store.GetString(settings.Key, prop.Name), out double value); prop.SetValue(settings, value); } } else if (prop.PropertyType == typeof(string)) { if (store.PropertyExists(settings.Key, prop.Name)) { prop.SetValue(settings, store.GetString(settings.Key, prop.Name)); } } } } catch (Exception ex) { Debug.Fail(ex.Message); } }
public UserSettingsContainer Load() { var result = new UserSettingsContainer(); if (!_settingsStore.CollectionExists(SETTINGS_STORE_NAME)) { Save(result); } if (_settingsStore.CollectionExists(SETTINGS_STORE_NAME)) { try { var content = _settingsStore.GetString(SETTINGS_STORE_NAME, "Settings"); result = UserSettingsContainer.DeserializeFromJson(content); return(result); } catch (Exception ex) { _logger.Error(ex); } } return(result); }
public static string GetTemplate(TestFramework testFramework, MockFramework mockFramework, TemplateType templateType) { string templateSettingKey = GetTemplateSettingsKey(testFramework, mockFramework, templateType); if (Store.PropertyExists(CollectionPath, templateSettingKey)) { return(Store.GetString(CollectionPath, templateSettingKey)); } switch (templateType) { case TemplateType.File: var templateGenerator = new DefaultTemplateGenerator(); return(templateGenerator.Get(testFramework, mockFramework)); case TemplateType.MockFieldDeclaration: return(mockFramework.MockFieldDeclarationCode); case TemplateType.MockFieldInitialization: return(mockFramework.MockFieldInitializationCode); case TemplateType.MockObjectReference: return(mockFramework.MockObjectReferenceCode); default: throw new ArgumentOutOfRangeException(nameof(templateType), templateType, null); } }
private void GitHubDialogWindowControl_OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs args) { if ((bool)args.NewValue == false) { return; } SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!userSettingsStore.CollectionExists("XamlToolkit")) { return; } var directory = userSettingsStore.GetString("XamlToolkit", "Directory"); if (string.IsNullOrWhiteSpace(directory)) { return; } try { GitHubDialogViewModel.UpdateDirectory(directory); GitHubDialogViewModel.Run(Path.Combine(directory, AppSettings.Default.ExePath)); Window.GetWindow(this).Close(); } catch (Exception) { GitHubDialogViewModel.SaveDirectorySettings(""); } }
/// <summary> /// Read from a settings store /// </summary> /// <typeparam name="T"></typeparam> /// <param name="subpath">The subcollection path (appended to the path passed to the constructor)</param> /// <param name="property">The property name to read</param> /// <param name="defaultValue">The default value to use in case the property doesn't exist. /// The type of the default value will be used to figure out the proper way to read the property, so if pass null, /// the property will be read as a string (which may or may not be what you want)</param> /// <returns></returns> public object Read(string subpath, string property, object defaultValue) { Guard.ArgumentNotNull(property, nameof(property)); Guard.ArgumentNotEmptyString(property, nameof(property)); var collection = subpath != null?Path.Combine(root, subpath) : root; store.CreateCollection(collection); if (defaultValue is bool) { return(store.GetBoolean(collection, property, (bool)defaultValue)); } else if (defaultValue is int) { return(store.GetInt32(collection, property, (int)defaultValue)); } else if (defaultValue is uint) { return(store.GetUInt32(collection, property, (uint)defaultValue)); } else if (defaultValue is long) { return(store.GetInt64(collection, property, (long)defaultValue)); } else if (defaultValue is ulong) { return(store.GetUInt64(collection, property, (ulong)defaultValue)); } return(store.GetString(collection, property, defaultValue?.ToString() ?? "")); }
static StaticBoilerplateSettings() { SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); Store = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); Store.CreateCollection(CollectionPath); 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); } }
public FormsPlayerViewModel([Import(typeof(SVsServiceProvider))] IServiceProvider services) { ConnectCommand = new DelegateCommand(Connect, () => !isConnected); DisconnectCommand = new DelegateCommand(Disconnect, () => isConnected); events = services.GetService <DTE>().Events.DocumentEvents; events.DocumentSaved += document => Publish(document.FullName); var manager = new ShellSettingsManager(services); settings = manager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!settings.CollectionExists(SettingsPath)) { settings.CreateCollection(SettingsPath); } if (settings.PropertyExists(SettingsPath, SettingsKey)) { SessionId = settings.GetString(SettingsPath, SettingsKey, ""); } if (string.IsNullOrEmpty(SessionId)) { // Initialize SessionId from MAC address. var mac = NetworkInterface.GetAllNetworkInterfaces() .Where(nic => nic.NetworkInterfaceType != NetworkInterfaceType.Loopback) .Select(nic => nic.GetPhysicalAddress().ToString()) .First(); SessionId = NaiveBijective.Encode(NaiveBijective.Decode(mac)); } TaskScheduler.UnobservedTaskException += OnTaskException; }
void LoadSettings() { SettingsManager settingsManager = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider); WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); string adb_path = configurationSettingsStore.GetString(StoreCategoryName, StorePropertyAdbPathName, ""); uint log_limit = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyLogsLimitName, 20000); bool is_auto = configurationSettingsStore.GetBoolean(StoreCategoryName, StorePropertyAutoScrollName, false); LogLimitCount = log_limit; adb.AdbExePath = adb_path; IsAutoScroll = is_auto; ColumnWidth[0] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyLevelWidthName, 60); ColumnWidth[1] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyTimeWidthName, 120); ColumnWidth[2] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyPidWidthName, 60); ColumnWidth[3] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyTagWidthName, 120); ColumnWidth[4] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyTextWidthName, 600); if (IsAutoScroll) { Dispatcher.InvokeAsync(() => { AutoScrollLabel.Content = "Auto Scroll On"; }); } else { Dispatcher.InvokeAsync(() => { AutoScrollLabel.Content = "Auto Scroll Off"; }); } }
public string GetFormat(string registryKey, string resourceKey) { string format = ""; try { format = settings.GetString(RegistryPath + registryKey, "Format").Replace("0*System.String*", ""); } catch { SetFormat(registryKey, resourceManager.GetString(resourceKey)); } if (format == null || format.ToLower() == "test" || format.Length == 0) { return(resourceManager.GetString(resourceKey)); } // A format always has to end with a new line char string[] lines = format.Split('\n'); if (lines[lines.Length - 1].Trim().Length > 0) { format += '\n'; } return(format); }
public object Read(string subPath, string property, object defaultValue) { Validate.IsNotNull(property, nameof(property)); Validate.IsNotEmpty(property, nameof(property)); var collection = subPath != null?Path.Combine(_root, subPath) : _root; _store.CreateCollection(collection); if (defaultValue is bool b) { return(_store.GetBoolean(collection, property, b)); } if (defaultValue is int i) { return(_store.GetInt32(collection, property, i)); } if (defaultValue is uint u) { return(_store.GetUInt32(collection, property, u)); } if (defaultValue is long l) { return(_store.GetInt64(collection, property, l)); } if (defaultValue is ulong ul) { return(_store.GetUInt64(collection, property, ul)); } return(_store.GetString(collection, property, defaultValue?.ToString() ?? "")); }
public Task <SettingsModel> GetSettingsAsync() { return(System.Threading.Tasks.Task.Run(() => { try { if (_writableSettingsStore.PropertyExists(CollectionPath, PropertyName)) { var settingsString = _writableSettingsStore.GetString(CollectionPath, PropertyName); return JsonConvert.DeserializeObject <SettingsModel>(settingsString); } } catch (Exception ex) { Debug.Fail(ex.Message); } return new SettingsModel() { WorkItemTypes = new List <SettingItemModel>(), WorkItemStatuses = new List <SettingItemModel>(), Columns = new List <SettingItemModel>(), DaysBackToQuery = 10, MaxWorkItems = 8 }; })); }
/// <summary> /// Loads from store. /// </summary> /// <param name="store">The store.</param> /// <param name="entry">The entry.</param> /// <param name="converter">The converter.</param> /// <returns></returns> private static object LoadFromStore(WritableSettingsStore store, string entry, TypeConverter converter) { ArgumentGuard.ArgumentNotNull(store, "store"); ArgumentGuard.ArgumentNotNullOrEmpty(entry, "entry"); ArgumentGuard.ArgumentNotNull(converter, "converter"); return(converter.ConvertFrom(store.GetString(CollectionName, entry))); }
private RoccatIskuFxFeedback GetFeedbackSettings(string collection) { if (!_writableSettingsStore.CollectionExists(collection)) { return(null); } var effect = (KeyEffect)Enum.Parse(typeof(KeyEffect), _writableSettingsStore.GetString(collection, "Effect")); var rgbColors = _writableSettingsStore.GetString(collection, "Color").Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToByte(x)).ToArray(); var color = Color.FromRgb(rgbColors[0], rgbColors[1], rgbColors[2]); return(new RoccatIskuFxFeedback { Effect = effect, Color = color }); }
public string ReadOption(string key) { if (_settingsStore.PropertyExists(SettingsRoot, key)) { return(_settingsStore.GetString(SettingsRoot, key)); } return(null); }
/// <summary> /// Loads DexterInfo from Settings Store /// </summary> /// <returns>loaded DexterInfo</returns> public DexterInfo Load() { if (!settingsStore.CollectionExists(DexterStoreName)) { return(new DexterInfo()); } else { return(new DexterInfo() { dexterHome = settingsStore.GetString(DexterStoreName, "dexterHome"), dexterServerIp = settingsStore.GetString(DexterStoreName, "dexterServerIp"), dexterServerPort = settingsStore.GetInt32(DexterStoreName, "dexterServerPort"), userName = settingsStore.GetString(DexterStoreName, "userName"), userPassword = settingsStore.GetString(DexterStoreName, "userPassword"), standalone = settingsStore.GetBoolean(DexterStoreName, "standalone") }); } }
private ShortcutFileInfo ExtractShortcutsInfoFromSettingsStore(string collectionName, string shortcutDef) { string collectionPath = $"{collectionName}\\{shortcutDef}"; // Extract values from UserSettingsStore string filepath = UserSettingsStore.GetString(collectionPath, FILEPATH); string name = UserSettingsStore.GetString(collectionPath, NAME); string extensionName = UserSettingsStore.GetString(collectionPath, EXTENSION_NAME); DateTime lastWriteTime = DateTime.Parse(UserSettingsStore.GetString(collectionPath, LAST_WRITE_TIME)); int flags = UserSettingsStore.GetInt32(collectionPath, FLAGS, 0); return(new ShortcutFileInfo() { Filepath = filepath, DisplayName = name, ExtensionName = extensionName, LastWriteTime = lastWriteTime, NotifyFlag = flags }); }
public static string GetTemplate(MockFramework mockFramework, TemplateType templateType) { string templateSettingKey = GetTemplateSettingsKey(mockFramework, templateType); if (Store.PropertyExists(CollectionPath, templateSettingKey)) { return(Store.GetString(CollectionPath, GetTemplateSettingsKey(mockFramework, templateType))); } return(GetDefaultTemplate(mockFramework, templateType)); }
public UserSettingsModel GetUserSettings() { SettingsManager settingsManager = new ShellSettingsManager(this); WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); ReferencesResolverExtensionPackage.EnsureSettingsStoreCollectionExists(userSettingsStore); string settingsJson = userSettingsStore.GetString(PathCollectionString, UserSettingsProperty, DefaultUserSettingsJson); UserSettingsModel userSettings = GetUserSettingsFromJson(settingsJson); return(userSettings); }
public string LoadString(string name, string category) { var path = GetCollectionPath(category); if (!_settingsStore.CollectionExists(path)) { return null; } if (!_settingsStore.PropertyExists(path, name)) { return null; } return _settingsStore.GetString(path, name, ""); }
/// <summary> /// Returns the value of the requested property whose data type is System.Uri /// </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> /// <returns>Uri or null if not set or not valid uri</returns> public static Uri GetUri(this WritableSettingsStore store, string collectionPath, string propertyName) { if (store.PropertyExists(collectionPath, propertyName)) { Uri uri = null; string value = store.GetString(collectionPath, propertyName); Uri.TryCreate(value, UriKind.Absolute, out uri); return(uri); } return(null); }