Ejemplo n.º 1
0
        ///<param name="region">Takes in the --region option from the code fence options in markdown</param>
        ///<param name="session">Takes in the --session option from the code fence options in markdown</param>
        ///<param name="package">Takes in the --package option from the code fence options in markdown</param>
        ///<param name="project">Takes in the --project option from the code fence options in markdown</param>
        ///<param name="args">Takes in any additional arguments passed in the code fence options in markdown</param>
        ///<see>To learn more see <a href="https://aka.ms/learntdn">our documentation</a></see>
        static async Task <int> Main(
            string region  = null,
            string session = null,
            string package = null,
            string project = null,
            string[] args  = null)
        {
            var regionsSelection = region switch
            {
                null => RegionSelection.All,
                _ => RegionSelection.Specific(region)
            };

            return(await Run(() => SampleRunner.Run(regionsSelection)));
        }
Ejemplo n.º 2
0
        public static async Task Run(RegionSelection region)
        {
            var runners = Runners.Value;

            async Task Execute(string regionName)
            {
                if (!runners.TryGetValue(regionName, out var action))
                {
                    throw new Exception($"Runner for region {regionName} not found");
                }

                await action();
            }

            await region.Match(async all =>
            {
                foreach (var runner in runners)
                {
                    await Execute(runner.Key);
                }
            }, specific => Execute(specific.RegionName));
        }