コード例 #1
0
        public void Write(string subPath, string property, object value)
        {
            Validate.IsNotNull(property, nameof(property));
            Validate.IsNotEmpty(property, nameof(property));

            var collection = subPath != null?Path.Combine(_root, subPath) : _root;

            _store.CreateCollection(collection);

            if (value is bool b)
            {
                _store.SetBoolean(collection, property, b);
            }
            else if (value is int i)
            {
                _store.SetInt32(collection, property, i);
            }
            else if (value is uint u)
            {
                _store.SetUInt32(collection, property, u);
            }
            else if (value is long l)
            {
                _store.SetInt64(collection, property, l);
            }
            else if (value is ulong ul)
            {
                _store.SetUInt64(collection, property, ul);
            }
            else
            {
                _store.SetString(collection, property, value?.ToString() ?? "");
            }
        }
コード例 #2
0
        public static void WriteSetting <T>(string propertyName, T propertyValue)
        {
            switch (Type.GetTypeCode(typeof(T)))
            {
            case TypeCode.String:
                _userSettingsStore.SetString(CollectionName, propertyName, Convert.ToString(propertyValue));
                break;

            case TypeCode.Boolean:
                _userSettingsStore.SetBoolean(CollectionName, propertyName, Convert.ToBoolean(propertyValue));
                break;

            case TypeCode.Int32:
                _userSettingsStore.SetInt32(CollectionName, propertyName, Convert.ToInt32(propertyValue));
                break;

            case TypeCode.Int64:
                _userSettingsStore.SetInt64(CollectionName, propertyName, Convert.ToInt64(propertyValue));
                break;

            case TypeCode.UInt32:
                _userSettingsStore.SetUInt32(CollectionName, propertyName, Convert.ToUInt32(propertyValue));
                break;

            case TypeCode.UInt64:
                _userSettingsStore.SetUInt64(CollectionName, propertyName, Convert.ToUInt64(propertyValue));
                break;

            default:
                _userSettingsStore.SetString(CollectionName, propertyName, Convert.ToString(propertyValue));
                break;
            }
        }
コード例 #3
0
ファイル: SettingsStore.cs プロジェクト: ehmz11/aaa
        public void Write(string subpath, string property, object value)
        {
            Guard.ArgumentNotNull(property, nameof(property));
            Guard.ArgumentNotEmptyString(property, nameof(property));

            var collection = subpath != null?Path.Combine(root, subpath) : root;

            store.CreateCollection(collection);

            if (value is bool)
            {
                store.SetBoolean(collection, property, (bool)value);
            }
            else if (value is int)
            {
                store.SetInt32(collection, property, (int)value);
            }
            else if (value is uint)
            {
                store.SetUInt32(collection, property, (uint)value);
            }
            else if (value is long)
            {
                store.SetInt64(collection, property, (long)value);
            }
            else if (value is ulong)
            {
                store.SetUInt64(collection, property, (ulong)value);
            }
            else
            {
                store.SetString(collection, property, value?.ToString() ?? "");
            }
        }
コード例 #4
0
        public void SetLastExtensionScanTime(long updateTimestamp)
        {
            string collectionPath = GENERAL_SETTINGS;

            UserSettingsStore.CreateCollection(collectionPath);
            UserSettingsStore.SetInt64(collectionPath, LAST_EXTENSION_SCAN_TIME, updateTimestamp);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: radical/roslyn-tools
        private static void UpdateLastExtensionsChange(WritableSettingsStore settingsStore)
        {
            const string ExtensionsChangedProperty = "ExtensionsChanged";

            if (!settingsStore.CollectionExists(ExtensionManagerCollectionPath))
            {
                settingsStore.CreateCollection(ExtensionManagerCollectionPath);
            }

            settingsStore.SetInt64(ExtensionManagerCollectionPath, ExtensionsChangedProperty, value: DateTime.UtcNow.ToFileTimeUtc());
        }
コード例 #6
0
        public void Save()
        {
            int i = 1;

            if (_settingsStore.CollectionExists("DebugAttachManagerProcesses"))
            {
                _settingsStore.DeleteCollection("DebugAttachManagerProcesses");
            }
            foreach (var p in Processes.Values)
            {
                _settingsStore.CreateCollection("DebugAttachManagerProcesses\\Process " + i);
                if (p.Title != null)
                {
                    _settingsStore.SetString("DebugAttachManagerProcesses\\Process " + i, "Title", p.Title);
                }
                if (p.RemoteServerName != null)
                {
                    _settingsStore.SetString("DebugAttachManagerProcesses\\Process " + i, "RemoteServerName", p.RemoteServerName);
                }
                if (p.RemotePortNumber.HasValue)
                {
                    _settingsStore.SetInt64("DebugAttachManagerProcesses\\Process " + i, "RemotePortNumber", p.RemotePortNumber.Value);
                }
                _settingsStore.SetString("DebugAttachManagerProcesses\\Process " + i, "ProcessName", p.ProcessName);
                _settingsStore.SetBoolean("DebugAttachManagerProcesses\\Process " + i, "Selected", p.Selected);

                if (p.DebugMode != null)
                {
                    _settingsStore.SetString("DebugAttachManagerProcesses\\Process " + i, "DebugMode", p.DebugMode);
                }
                i++;
            }
            if (!_settingsStore.CollectionExists("DebugAttachManagerProcesses"))
            {
                _settingsStore.CreateCollection("DebugAttachManagerProcesses");
            }
            if (!string.IsNullOrEmpty(RemoteServer))
            {
                _settingsStore.SetString("DebugAttachManagerProcesses", "RemoteServer", RemoteServer);
            }
            if (!string.IsNullOrEmpty(RemotePort))
            {
                _settingsStore.SetString("DebugAttachManagerProcesses", "RemotePort", RemotePort);
            }
            if (!string.IsNullOrEmpty(RemoteUserName))
            {
                _settingsStore.SetString("DebugAttachManagerProcesses", "RemoteUserName", RemoteUserName);
            }
            for (i = 0; i < Constants.NUMBER_OF_OPTIONAL_COLUMNS; i++)
            {
                string columnName = $"Column{i}";
                _settingsStore.SetBoolean("DebugAttachManagerProcesses", columnName, _processesColumns[i]);
            }
        }
コード例 #7
0
        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;
            }
        }