예제 #1
0
        public static int Main(string[] args)
        {
            if (args?.Length != 1)
            {
                Console.WriteLine("No EnvKey set!");
                return(1);
            }

            var envKeyToTest = args[0];

            var options = new EnvKeyOptions
            {
                EnvKey   = envKeyToTest,
                UseCache = false
            };
            var envKey = new EnvKeyConfig(options);

            var success = envKey.TryLoadRaw(out var config);

            Console.WriteLine($"Can load as raw? {success}");
            Console.WriteLine($"Config: {config.Trim()}");

            success = envKey.TryLoad(out var configDir);
            Console.WriteLine($"Can load as json? {success}");
            Console.WriteLine($"Config Count: {configDir.Count}");
            foreach (var kvp in configDir)
            {
                Console.WriteLine($"{kvp.Key}: {kvp.Value}");
            }

            var countBefore = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Process).Count;

            success = envKey.TryLoadIntoEnvironment();
            var countAfter = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Process).Count;

            Console.WriteLine($"Can load into environment variables? {success}");
            Console.WriteLine($"Process EnvVars changed? {(countAfter - countBefore) > 0}");

            return(0);
        }
예제 #2
0
        public Startup(IConfiguration configuration)
        {
            var envKey = new EnvKeyConfig();

            envKey.Load();
        }