public int WriteUserOptions(IStream pOptionsStream, string pszKey)
        {
            string value;

            switch (pszKey)
            {
            case SELECTED_WEB_RESOURCES:
                value = SimpleJson.SerializeObject(DevKitSetting.SelectedWebResources);
                break;

            case SELECTED_REPORTS:
                value = SimpleJson.SerializeObject(DevKitSetting.SelectedReports);
                break;

            default:
                return(VSConstants.S_OK);
            }
            using (StreamEater wrapper = new StreamEater(pOptionsStream))
            {
                using (var bw = new System.IO.BinaryWriter(wrapper))
                {
                    bw.Write(value);
                }
            }
            return(VSConstants.S_OK);
        }
        public int ReadUserOptions(IStream pOptionsStream, [ComAliasName("Microsoft.VisualStudio.OLE.Interop.LPCOLESTR")] string pszKey)
        {
            using (StreamEater wrapper = new StreamEater(pOptionsStream))
            {
                string value;
                using (var bReader = new System.IO.BinaryReader(wrapper))
                {
                    value = bReader.ReadString();
                }
                try
                {
                    switch (pszKey)
                    {
                    case SELECTED_WEB_RESOURCES:
                        DevKitSetting.SelectedWebResources = SimpleJson.DeserializeObject <List <SavedMappingWebResource> >(value);
                        break;

                    case SELECTED_REPORTS:
                        DevKitSetting.SelectedReports = SimpleJson.DeserializeObject <List <SavedMappingReport> >(value);
                        break;
                    }
                }
                catch { }
            }
            return(VSConstants.S_OK);
        }
        public int ReadUserOptions(IStream pOptionsStream, string pszKey)
        {
            try {
                using (StreamEater wrapper = new StreamEater(pOptionsStream)) {
                    try {
                        StoreType type = getTypeFromKey(pszKey);
                        stores[type].readOptions(wrapper);
// ReSharper disable EmptyGeneralCatchClause
                    } catch (Exception) {
// ReSharper restore EmptyGeneralCatchClause
                    }
                }
                return(VSConstants.S_OK);
            }
            finally {
                Marshal.ReleaseComObject(pOptionsStream);
            }
        }
Example #4
0
        public int WriteUserOptions(IStream pOptionsStream, string pszKey)
        {
            try
            {
                string value;
                switch (pszKey)
                {
                case _strSolutionPersistanceKey + _strUsername:
                    value = _settings.Username;
                    break;

                case _strSolutionPersistanceKey + _strPassword:
                    value = _settings.Password;
                    break;

                default:
                    return(VSConstants.S_OK);
                }

                using (var aes = new SimpleAES())
                {
                    value = aes.Encrypt(value);
                    using (StreamEater wrapper = new StreamEater(pOptionsStream))
                    {
                        using (var bw = new System.IO.BinaryWriter(wrapper))
                        {
                            bw.Write(value);
                        }
                    }
                }
                return(VSConstants.S_OK);
            }
            finally
            {
                Marshal.ReleaseComObject(pOptionsStream);
            }
        }
Example #5
0
        public int ReadUserOptions(IStream pOptionsStream, string pszKey)
        {
            try
            {
                using (StreamEater wrapper = new StreamEater(pOptionsStream))
                {
                    string value;
                    using (var bReader = new System.IO.BinaryReader(wrapper))
                    {
                        value = bReader.ReadString();
                        using (var aes = new SimpleAES())
                        {
                            value = aes.Decrypt(value);
                        }
                    }

                    switch (pszKey)
                    {
                    case _strSolutionPersistanceKey + _strUsername:
                        _settings.Username = value;
                        break;

                    case _strSolutionPersistanceKey + _strPassword:
                        _settings.Password = value;
                        break;

                    default:
                        break;
                    }
                }
                return(VSConstants.S_OK);
            }
            finally
            {
                Marshal.ReleaseComObject(pOptionsStream);
            }
        }