private void EnsureLoaded()

in TeamCity.CSharpInteractive/Settings.cs [110:158]


    private void EnsureLoaded()
    {
        lock (_lockObject)
        {
            if (_isLoaded)
            {
                return;
            }

            _isLoaded = true;
            var defaultArgType = _runningMode switch
            {
                RunningMode.Tool => CommandLineArgumentType.ScriptFile,
                RunningMode.Application => CommandLineArgumentType.ScriptArgument,
                _ => CommandLineArgumentType.ScriptFile
            };

            var args = _commandLineParser.Parse(
                    _environment.GetCommandLineArgs().Skip(1),
                    defaultArgType)
                .ToImmutableArray();

            var props = new Dictionary<string, string>();
            _scriptProperties = props;
            foreach (var (_, value, key) in args.Where(i => i.ArgumentType == CommandLineArgumentType.ScriptProperty))
            {
                props[key] = value;
            }

            _nuGetSources = args.Where(i => i.ArgumentType == CommandLineArgumentType.NuGetSource).Select(i => i.Value);
            if (_runningMode == RunningMode.Application
                || args.Any(i => i.ArgumentType == CommandLineArgumentType.ScriptFile)
                || args.Any(i => i.ArgumentType == CommandLineArgumentType.Help))
            {
                _interactionMode = InteractionMode.NonInteractive;
                _verbosityLevel = VerbosityLevel.Normal;
                _showHelpAndExit = args.Any(i => i.ArgumentType == CommandLineArgumentType.Help);
                _showVersionAndExit = args.Any(i => i.ArgumentType == CommandLineArgumentType.Version);
                _scriptArguments = args.Where(i => i.ArgumentType == CommandLineArgumentType.ScriptArgument).Select(i => i.Value).ToImmutableArray();
                _codeSources = args.Where(i => i.ArgumentType == CommandLineArgumentType.ScriptFile).Select(i => _fileCodeSourceFactory(i.Value));
            }
            else
            {
                _interactionMode = InteractionMode.Interactive;
                _verbosityLevel = VerbosityLevel.Quiet;
                _codeSources = new[] {_consoleCodeSource};
            }
        }
    }