forked from npgsql/npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostgresEnvironment.cs
More file actions
30 lines (21 loc) · 1.11 KB
/
PostgresEnvironment.cs
File metadata and controls
30 lines (21 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.IO;
using Npgsql.Util;
namespace Npgsql
{
static class PostgresEnvironment
{
public static string? User => Environment.GetEnvironmentVariable("PGUSER");
public static string? Password => Environment.GetEnvironmentVariable("PGPASSWORD");
public static string? PassFile => Environment.GetEnvironmentVariable("PGPASSFILE");
public static string? PassFileDefault => GetDefaultFilePath(PGUtil.IsWindows ? "pgpass.conf" : ".pgpass");
public static string? SslCert => Environment.GetEnvironmentVariable("PGSSLCERT");
public static string? SslCertDefault => GetDefaultFilePath("postgresql.crt");
public static string? ClientEncoding => Environment.GetEnvironmentVariable("PGCLIENTENCODING");
public static string? TimeZone => Environment.GetEnvironmentVariable("PGTZ");
static string? GetDefaultFilePath(string fileName) =>
Environment.GetEnvironmentVariable(PGUtil.IsWindows ? "APPDATA" : "HOME") is string appData
? Path.Combine(appData, "postgresql", fileName)
: null;
}
}