public DateTime GetTestRunStartedTime() { if (_environmentWrapper.GetEnvironmentVariable(SpecFlowMessagesTestRunStartedTimeOverrideName) is ISuccess <string> success && TryParseUniversalDateTime(success.Result, out var dateTime)) { return(dateTime); } return(_clock.GetNowDateAndTime()); }
private string GetBuildServerName() { foreach (var buildServerType in buildServerTypes) { var envVariable = _environmentWrapper.GetEnvironmentVariable(buildServerType.Key); if (envVariable is ISuccess <string> ) { return(buildServerType.Value); } } return(null); }
public void LoadConfig(string configFilePath) { if (string.IsNullOrWhiteSpace(configFilePath)) { var envVariableConfigFilePath = environmentWrapper.GetEnvironmentVariable("tsqllintrc"); if (fileSystem.File.Exists(envVariableConfigFilePath)) { LoadConfigFromFile(envVariableConfigFilePath); return; } var localConfigFilePath = Path.Combine(Environment.CurrentDirectory, @".tsqllintrc"); if (fileSystem.File.Exists(localConfigFilePath)) { LoadConfigFromFile(localConfigFilePath); return; } var defaultConfigFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @".tsqllintrc"); if (fileSystem.File.Exists(defaultConfigFilePath)) { LoadConfigFromFile(defaultConfigFilePath); return; } // load in memory config var configFileGenerator = new ConfigFileGenerator(); LoadConfigFromJson(configFileGenerator.GetDefaultConfigRules()); } else { LoadConfigFromFile(configFilePath); } }
private string ReplaceSqlPlaceholders(string sql) { var matches = PlaceholderRegex.Matches(sql); if (matches.Count == 0) { return(sql); } var newSql = new StringBuilder(); var i = 0; foreach (Match match in matches) { var placeholder = match.Groups["placeholder"].Value; var replacement = environmentWrapper.GetEnvironmentVariable(placeholder) ?? match.Value; newSql.Append(sql.Substring(i, match.Index - i)); newSql.Append(replacement); i = match.Index + match.Length; } newSql.Append(sql.Substring(i)); return(newSql.ToString()); }
public APIGatewayProxyResponse GetVersion(APIGatewayProxyRequest request, ILambdaContext context) { var versionInfo = new VersionInfo { Version = _env.GetEnvironmentVariable("Version") }; return(_responseWrapper.Success(versionInfo)); }
public void Add(DirectoryPath value, PathSettings pathSettings) { if (value == null) { throw new ArgumentNullException(nameof(value), "Value to add to path is null."); } if (pathSettings == null) { throw new ArgumentNullException(nameof(pathSettings), "Path settings is null."); } var pathTarget = pathSettings .Target .GetValueOrDefault(PathTarget.User); var parts = _environmentWrapper .GetEnvironmentVariable("PATH", pathTarget, string.Empty) .Split(';') .Where(x => !string.IsNullOrWhiteSpace(x)) .ToList(); if (parts.Contains(value.FullPath)) { _log.Verbose($"PATH already contains '{value}'."); return; } parts.Add(value.FullPath); _environmentWrapper.SetEnvironmentVariable("PATH", string.Join(";", parts), pathTarget); _log.Verbose($"Added '{value}' to PATH."); }
private void ApplyTransformations(string webConfig) { using (var webConfigManager = new WebConfigManager(_fileWrapper, _xmlDocumentWrapper, webConfig)) { var environment = _environmentWrapper.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Release"; Console.WriteLine($"-----> Using Environment: {environment}"); var config = _configurationFactory.GetConfiguration(environment); var transform = new WebConfigTransformHandler(config, webConfigManager); transform.CopyExternalAppSettings(webConfigManager); transform.CopyExternalConnectionStrings(webConfigManager); transform.CopyExternalTokens(webConfigManager); } }
public void ApplyXmlTransformation(string buildPath, IEnvironmentWrapper environmentWrapper, IWebConfigWriter webConfigWriter) { if (webConfigWriter == null) { throw new ArgumentNullException(nameof(webConfigWriter), "WebConfig writer is required"); } var transformationKey = environmentWrapper.GetEnvironmentVariable(Constants.XML_TRANSFORM_KEY_NM) ?? "Release"; var transformFilePath = Path.Combine(buildPath, $"web.{transformationKey}.config"); if (File.Exists(transformFilePath)) { webConfigWriter.ExecuteXmlTransformation(transformFilePath); } }
private void ApplyTransformations(string buildPath, string webConfig) { using (var webConfigManager = new WebConfigManager(_fileWrapper, _xmlDocumentWrapper, _logger, webConfig)) { var environment = _environmentWrapper.GetEnvironmentVariable(Constants.ASPNETCORE_ENVIRONMENT_NM) ?? "Release"; _logger.WriteLog($"-----> Using Environment: {environment}"); var config = _configurationFactory.GetConfiguration(environment); _tracer.FlushEnvironmentVariables(); var transform = new WebConfigTransformHandler(config, webConfigManager); transform.ApplyXmlTransformation(buildPath, _environmentWrapper, webConfigManager); transform.CopyExternalAppSettings(webConfigManager); transform.CopyExternalConnectionStrings(webConfigManager); transform.CopyExternalTokens(webConfigManager); } }
public bool IsTraceConfigEnabled() { return(Convert.ToBoolean(environmentWrapper.GetEnvironmentVariable(Constants.TRACE_CONFIG_ENABLED_NM) ?? "false") && (environmentWrapper.GetEnvironmentVariable(Constants.ASPNETCORE_ENVIRONMENT_NM) ?? "Release").ToLower().Contains("dev")); }
public ConfigurationTracer(IEnvironmentWrapper environmentWrapper, IConfigurationFactory configurationFactory, ILogger logger) { _configuration = configurationFactory.GetConfiguration(environmentWrapper.GetEnvironmentVariable(Constants.ASPNETCORE_ENVIRONMENT_NM) ?? "Release"); this.environmentWrapper = environmentWrapper; _logger = logger; }