public static void CopyProperty(this IVsWritableSettingsStore store, SettingsStoreProperty from, string toName)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var fromName       = from.Name;
            var collectionPath = from.CollectionPath;

            switch (from.Type)
            {
            case __VsSettingsType.SettingsType_String:
                ErrorHandler.ThrowOnFailure(store.GetString(collectionPath, fromName, out var stringValue));
                ErrorHandler.ThrowOnFailure(store.SetString(collectionPath, toName, stringValue));
                break;

            case __VsSettingsType.SettingsType_Int:
                ErrorHandler.ThrowOnFailure(store.GetInt(collectionPath, fromName, out var intValue));
                ErrorHandler.ThrowOnFailure(store.SetInt(collectionPath, toName, intValue));
                break;

            case __VsSettingsType.SettingsType_Int64:
                ErrorHandler.ThrowOnFailure(store.GetInt64(collectionPath, fromName, out var longValue));
                ErrorHandler.ThrowOnFailure(store.SetInt64(collectionPath, toName, longValue));
                break;

            case __VsSettingsType.SettingsType_Binary:
                uint[] actualByteLength = { 0 };
                ErrorHandler.ThrowOnFailure(store.GetBinary(collectionPath, fromName, 0, null, actualByteLength));
                byte[] bytes = new byte[actualByteLength[0]];
                ErrorHandler.ThrowOnFailure(store.GetBinary(collectionPath, fromName, actualByteLength[0], bytes, actualByteLength));
                ErrorHandler.ThrowOnFailure(store.SetBinary(collectionPath, toName, actualByteLength[0], bytes));
                break;
            }
        }
示例#2
0
        private void LoadOption <T>(EditorOptionKey <T> key)
        {
            string collection = GetCollectionName(key.Name);
            string property   = GetPropertyName(key.Name);

            int ivalue = 0;

            if (VSConstants.S_OK == _store.CollectionExists(collection, out ivalue))
            {
                ivalue = 2;
            }

            string svalue;

            if (VSConstants.S_OK == _store.GetString(collection, property, out svalue))
            {
                if (typeof(T) == typeof(bool))
                {
                    bool value = bool.Parse(svalue);
                    _options.SetOptionValue(key.Name, value);
                }
                else if (typeof(T) == typeof(uint))
                {
                    uint argb = uint.Parse(svalue);
                    _options.SetOptionValue(key.Name, argb);
                }
            }
        }