Esempio n. 1
0
        static void Main(string[] args)
        {
            BurgerMaster burgerMaster = new BurgerMaster();

            var stopwatch = new System.Diagnostics.Stopwatch();

            stopwatch.Start();

            Task <Patty> pattyTask   = burgerMaster.CookPattyAsync();
            var          friesTask   = burgerMaster.FryFriesAsync();
            var          produceTask = burgerMaster.ChopProduceAsync();
            var          bunTask     = burgerMaster.ToastBunAsync();

            // Cook patty
            Patty patty = pattyTask.Result;

            // Fry some fries
            Fries fries = friesTask.Result;

            // Chop some veggies
            Produce produce = produceTask.Result;

            // Toasted bun
            Bun bun = bunTask.Result;

            // Assemble burger
            Burger burger = burgerMaster.AssembleBurger();

            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedMilliseconds);
            Console.ReadKey();
        }
 public Burger(Bread bread, Patty patty, Sauce sauce, Cheese cheese)
 {
     Bread  = bread;
     Patty  = patty;
     Sauce  = sauce;
     Cheese = cheese;
 }
Esempio n. 3
0
        public void Run()
        {
            BurgerMaster burgerMaster = new BurgerMaster();

            Patty patty = burgerMaster.CookPatty();

            Console.WriteLine("Patty Done");
            Fries fries = burgerMaster.FryFries();

            Console.WriteLine("Fries Done");
            Bun bun = burgerMaster.ToastBun();

            Console.WriteLine("Bun Toasted");
            Produce produce = burgerMaster.ChopProduce();

            Console.WriteLine("Produce Chopped");

            burgerMaster.AssembleBurger();
            Console.WriteLine("Enjoy Burger");

            Console.ReadKey();
        }
Esempio n. 4
0
 public Tests()
 {
     patty = new Patty();
 }
Esempio n. 5
0
        private static void Main(string[] args)
        {
            var app = new CommandLineApplication
            {
                Name        = "Patty",
                Description =
                    "Provided with set of samples and regexs called pattern fragments, builds up a list of patterns which matches these samples."
            };

            app.HelpOption("-?|-h|--help");
            var patternsFile = app.Option("-p |--patterns-file <filepath>", "File with pattern fragments to be used",
                                          CommandOptionType.SingleValue);

            var samples = app.Option("-s |--samples <filepath>", "Source of samples", CommandOptionType.SingleValue);

            app.OnExecute(() =>
            {
                if (!samples.HasValue() || !System.IO.File.Exists(samples.Value()))
                {
                    app.Error.WriteLine("sample file not exist or not provided");

                    return(1);
                }

                var patty = new Patty();

                if (patternsFile.HasValue())
                {
                    if (System.IO.File.Exists(patternsFile.Value()))
                    {
                        using (var reader = new System.IO.StreamReader(patternsFile.Value())) {
                            string pattern;
                            while ((pattern = reader.ReadLine()) != null)
                            {
                                patty.AddPatternFragment(pattern);
                            }
                        }
                    }
                    else
                    {
                        app.Error.WriteLine($"patterns file does not exists - {patternsFile.Value()}");
                    }
                }

                using (var reader = new System.IO.StreamReader(samples.Value())) {
                    string sample;
                    while ((sample = reader.ReadLine()) != null)
                    {
                        patty.AddSample(sample);
                    }
                }

                var result = patty.CompileAll();
                foreach (var item in result)
                {
                    app.Out.WriteLine(item);
                }

                return(0);
            });

            app.Execute(args);
        }