/// <summary> /// Searches the path variable for the first match of exeToSearchFor. Returns /// null if not found. /// </summary> private string?GetFullPathOfExeFromEnvironmentPath(string exeToSearchFor) { string pathEnv = _environment.GetEnvironmentVariable("Path"); if (string.IsNullOrEmpty(pathEnv)) { return(null); } foreach (string path in new LazyStringSplit(pathEnv, ';')) { // We don't want one bad path entry to derail the search try { string exePath = Path.Combine(path, exeToSearchFor); if (_fileSystem.FileExists(exePath)) { return(exePath); } } catch (ArgumentException) { } } return(null); }
private bool IsEnvironmentVariableEnabled(string variable, ref bool?result) { if (result == null) { string value = _environment.GetEnvironmentVariable(variable); result = string.Equals(value, "1", StringComparison.OrdinalIgnoreCase); } return(result.Value); }
public NpgsqlConnection CreateConnection() { var connectionString = _environmentHelper.GetEnvironmentVariable("DbAttensiTechTest"); if (string.IsNullOrWhiteSpace(connectionString)) { throw new ArgumentNullException("Connection string to DbAttensiTechTest is not found"); } Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true; return(new NpgsqlConnection(connectionString)); }
private bool IsEnabled(string variable) { string value = _environment.GetEnvironmentVariable(variable); return(string.Equals(value, "1", StringComparison.OrdinalIgnoreCase)); }