Пример #1
0
        public MyAppSettingsBridge(IOptionsMonitor <MyAppSettings> appSettings, ISettingsDecrypt decryptor, ISettingsValidator validator)
        {
            var appSettingsUnwrapped = appSettings?.CurrentValue ?? throw new ArgumentNullException(nameof(appSettings));

            if (decryptor is null)
            {
                throw new ArgumentException(nameof(decryptor));
            }

            if (validator is null)
            {
                throw new ArgumentNullException(nameof(validator));
            }

            if (!validator.TryValidate(appSettingsUnwrapped, out var validationException))
            {
                throw validationException;
            }

            ApplicationName = appSettingsUnwrapped.ApplicationName;

            SqlConnectionSting = decryptor.Decrypt("Sql", appSettingsUnwrapped.Secrets);

            OracleConnectionSting = decryptor.Decrypt("Oracle", appSettingsUnwrapped.Secrets);
        }
        public MyAppSettingsBridge(IOptionsSnapshot <MyAppSettings> appSettings, ISettingsDecrypt decryptor, ISettingsValidator validator)
        {
            _appSettings = appSettings ?? throw new ArgumentNullException(nameof(appSettings));
            _decryptor   = decryptor ?? throw new ArgumentException(nameof(decryptor));
            if (validator == null)
            {
                throw new ArgumentNullException(nameof(validator));
            }

            if (!validator.TryValidate(appSettings.Value, out var validationException))
            {
                throw validationException;
            }
        }