private static()

in Hands-on lab/lab-files/TransactionGenerator/Program.cs [305:350]


        private static (string EventHubConnectionString,
                        string EventHub2ConnectionString,
                        string EventHub3ConnectionString,
                        string CosmosDbEndpointUrl,
                        string CosmosDbAuthorizationKey,
                        int MillisecondsToRun,
                        int MillisecondsToLead,
                        bool OnlyWriteToCosmosDb) ParseArguments()
        {
            try
            {
                // The Configuration object will extract values either from the machine's environment variables, or the appsettings.json file.
                var eventHubConnectionString = _configuration["EVENT_HUB_1_CONNECTION_STRING"];
                var eventHub2ConnectionString = _configuration["EVENT_HUB_2_CONNECTION_STRING"];
                var eventHub3ConnectionString = _configuration["EVENT_HUB_3_CONNECTION_STRING"];
                var cosmosDbEndpointUrl = _configuration["COSMOS_DB_ENDPOINT"];
                var cosmosDbAuthorizationKey = _configuration["COSMOS_DB_AUTH_KEY"];
                var numberOfMillisecondsToRun = (int.TryParse(_configuration["SECONDS_TO_RUN"], out var outputSecondToRun) ? outputSecondToRun : 0) * 1000;
                var numberOfMillisecondsToLead = (int.TryParse(_configuration["SECONDS_TO_LEAD"], out var outputSecondsToLead) ? outputSecondsToLead : 0) * 1000;
                bool.TryParse(_configuration["ONLY_WRITE_TO_COSMOS_DB"], out var onlyWriteToCosmosDb);

                if (string.IsNullOrWhiteSpace(eventHubConnectionString) && !onlyWriteToCosmosDb)
                {
                    throw new ArgumentException("EVENT_HUB_CONNECTION_STRING must be provided");
                }

                if (string.IsNullOrWhiteSpace(cosmosDbEndpointUrl))
                {
                    throw new ArgumentException("COSMOS_DB_ENDPOINT must be provided");
                }

                if (string.IsNullOrWhiteSpace(cosmosDbAuthorizationKey))
                {
                    throw new ArgumentException("COSMOS_DB_AUTH_KEY must be provided");
                }

                return (eventHubConnectionString, eventHub2ConnectionString, eventHub3ConnectionString, cosmosDbEndpointUrl, cosmosDbAuthorizationKey,
                    numberOfMillisecondsToRun, numberOfMillisecondsToLead, onlyWriteToCosmosDb);
            }
            catch (Exception e)
            {
                WriteLineInColor(e.Message, ConsoleColor.Red);
                Console.ReadLine();
                throw;
            }
        }