예제 #1
0
    public static async Task <int> RunSolver(string[] args, IServiceCollection services)
    {
        DotEnv.Fluent()
        .WithoutExceptions()
        .WithEnvFiles()
        .WithTrimValues()
        .WithDefaultEncoding()
        .WithOverwriteExistingVars()
        .WithProbeForEnv(6)
        .Load();

        SetWorkingDirectory();

        ConfigureServices(services);
        ServiceProvider serviceProvider = BuildServiceProvider(services);
        var             solver          = serviceProvider.GetRequiredService <Solver>();

        var all = false;

        switch (args.Length)
        {
        // dotnet run
        case 0:
            await solver.SolveLast().ConfigureAwait(false);

            break;

        // dotnet run all | dotnet run --all
        case 1 when args[0].Contains("all", StringComparison.CurrentCultureIgnoreCase):
예제 #2
0
        /// <summary>
        /// Reads the file and returns a new <see cref="EnvironmentViewModel"/>.
        /// </summary>
        /// <returns>An <see cref="EnvironmentViewModel"/> with variables read from the dotEnv file.</returns>
        public EnvironmentViewModel Process()
        {
            var newVariables         = DotEnv.Fluent().WithEnvFiles(_inputFile).Read();
            var environmentViewModel = new EnvironmentViewModel();

            environmentViewModel.Name = _inputFile;
            foreach (var variable in newVariables)
            {
                var environmentVariable = new EnvironmentVariableViewModel();
                environmentVariable.Name  = variable.Key;
                environmentVariable.Value = variable.Value;

                if (environmentVariable.Name == "_CHAMI_ENV")
                {
                    environmentViewModel.Name = environmentVariable.Value;
                }
                else
                {
                    environmentViewModel.EnvironmentVariables.Add(environmentVariable);
                }
            }

            return(environmentViewModel);
        }