private static IAppEnvVars GetAppEnvVars() { var envPath = EnvVariablesRetriever.GetRealBasePath(); //For VM Must be configured Program.RealPath = (String.IsNullOrEmpty(envPath)) ? Directory.GetCurrentDirectory() : envPath; var path = Path.Combine(RealPath, "Configs", "Enviroment", "appenviroment.json"); if (File.Exists(path)) { var doc = File.ReadAllText(path); try { var objectVars = JsonConvert.DeserializeObject <MyAuthAppEnvVars>(doc); return(objectVars); } catch (Exception e) { Console.WriteLine($"Error: {e.Message}, {e.StackTrace}"); goto FailureMain; } } FailureMain : return(null); }
//Created For Migration creation and update database connection string selection its a result of env value ASPENVMAINACT public static string GetAppActiveConnectionStringOrDevelopment(this IConfiguration config) => (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPENVMAINACT"))) ? "Host=localhost;Database=MyAuth;Username=postgres;Password=Margoleta16!" : config.GetConnectionString(EnvVariablesRetriever.GetAppActiveConnectionString());