Beispiel #1
0
        public Settings GetSettings()
        {
            var settings = new Settings
            {
                KleinerBrauhelfer =
                {
                    Database = _appSettings[BrauhelferDbKey]
                },
                Git =
                {
                    User     = _appSettings[UserKey],
                    Password = Cryptograph.Decrypt(_appSettings[PasswordKey]),
                    Token    = Cryptograph.Decrypt(_appSettings[TokenKey])
                },
                Sql =
                {
                    Server   = _appSettings[SqlServerKey],
                    Database = _appSettings[SqlDatabaseKey],
                    User     = _appSettings[SqlUserKey],
                    Password = Cryptograph.Decrypt(_appSettings[SqlPassKey])
                }
            };

            return(settings);
        }
Beispiel #2
0
        private static void AddOrSetValue(ref System.Configuration.Configuration configFile, string key, string value, bool crypt = false)
        {
            var encryptedValue = crypt ? Cryptograph.Encrypt(value) : value;

            var settings = configFile.AppSettings.Settings;

            if (settings[key] == null)
            {
                settings.Add(key, encryptedValue);
            }
            else
            {
                settings[key].Value = encryptedValue;
            }
        }