コード例 #1
0
        /// <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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        private bool IsEnabled(string variable)
        {
            string value = _environment.GetEnvironmentVariable(variable);

            return(string.Equals(value, "1", StringComparison.OrdinalIgnoreCase));
        }