Exemplo n.º 1
0
 private static PostgresOptions CreatePostgresOptions(IPostgresOptions options)
 {
     return(new PostgresOptions((key, value) =>
     {
         var envFlag = Environment.GetEnvironmentVariable(key.ToUpperInvariant());
         return !string.IsNullOrEmpty(envFlag) ? envFlag : PostgresOptions.GetFromIOptions(options, key, value);
     }));
 }
Exemplo n.º 2
0
        public static string GetFromIOptions(IPostgresOptions options, string key, string value)
        {
            var optionValue = key switch
            {
                HostFlagName => options.PostgresHost,
                UserNameFlagName => options.PostgresUserName,
                PasswordFlagName => options.PostgresPassword,
                DatabaseFlagName => options.PostgresDatabase,
                AdditionalFlagName => options.PostgresAdditionalOptions,
                _ => throw new InvalidOperationException($"Unknown Postgres flag {key}")
            };

            return(string.IsNullOrEmpty(optionValue) ? value : optionValue);
        }
Exemplo n.º 3
0
 public PostgresOptions(IPostgresOptions options)
     : this((key, value) => GetFromIOptions(options, key, value))
 {
 }