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() ?? "");
            }
        }
Exemplo n.º 2
0
        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() ?? "");
            }
        }
Exemplo n.º 3
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;
            }
        }
Exemplo n.º 4
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();
        }