예제 #1
0
 public static bool IsSubscribed(ItemDetails item)
 {
     if (Vanilla.IsVanilla(item.WorkshopId))
     {
         return(true);
     }
     // TODO
     return(false);
 }
예제 #2
0
        static void Main(string[] args)
        {
            IceCream iceCream = new Vanilla();

            iceCream = new Sprinkle(iceCream);

            iceCream = new Fudge(iceCream);

            Console.WriteLine(iceCream.Cost());

            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            IBeverage b1 = new Coffee();

            b1 = new Milk(b1);
            b1 = new Milk(b1);
            b1 = new Vanilla(b1);


            Console.WriteLine($"Price: {b1.getPrice()}");
            Console.ReadLine();
        }
예제 #4
0
        private List <string> GetInstalledPalettes()
        {
            var colors = Vanilla.Descendants().Where(key => (string)key.Attribute("name") == "Colors");

            var name =
                colors.Descendants()
                .Elements("value")
                .Where(value => (string)value.Attribute("name") == "Name" && value.AttributeOrEmpty("data").Value != "")
                .Select(value => value.AttributeOrEmpty("data").Value);

            return(name.ToList());
        }
예제 #5
0
        private static void TestDecoratorPattern()
        {
            Beverage coffee = new Coffee();

            Console.WriteLine("{0}....{1}", coffee.getDescription(), coffee.getCost());

            Beverage vanillaCoffee = new Vanilla(new Coffee());

            Console.WriteLine("{0}....{1}", vanillaCoffee.getDescription(), vanillaCoffee.getCost());

            Beverage CaramelVanillaCoffee = new Caramel(new Vanilla(new Coffee()));

            Console.WriteLine("{0}....{1}", CaramelVanillaCoffee.getDescription(), CaramelVanillaCoffee.getCost());
        }
예제 #6
0
        static void Main(string[] args)
        {
            AbstractCookie c1 = new BakedCookie();

            Console.WriteLine(c1.GetDescription());

            Vanilla c2 = new Vanilla(c1);

            Console.WriteLine(c2.GetDescription());

            Chocolate c3 = new Chocolate(c2);

            Console.WriteLine(c3.GetDescription());

            AbstractCookie c4 = new Chocolate(new Vanilla(new FrozenCookie()));

            Console.WriteLine(c4.GetDescription());
        }
예제 #7
0
        private void InitializeColorPalette()
        {
            Log("Initializing Color Palettes");
            var date            = DateTime.Now;
            var defaultPallette =
                new XElement("key",
                             new XAttribute("name", "Colors"),
                             new XAttribute("modified", date.ToString("yyyy-MM-dd H:mm:ss")),
                             new XAttribute("build", Build),
                             new XElement("value",
                                          new XAttribute("name", "Count"),
                                          new XAttribute("type", "dword"),
                                          new XAttribute("data", ColorCount.ToString("00000000"))
                                          )
                             );

            Vanilla.Add(defaultPallette);
            ColorCount++;
        }
        public void Test_Custom_Field_Processor()
        {
            /*
             * The following is a contrive example of doing Avro serialization to an
             * existing DTO/model with some special requirements and cannot be modified
             */

            /*
             * Scenario: We are sending a trade request down the wire with fields that can be set but not retrieve
             * and which has impact to non-pure properties e.g. throws an exception if a method is not called before
             * retrieving the property value
             */

            var schema = Resources.TradeRequest;

            var trade = new Vanilla();
            var tenor = new Tenor(3);

            trade.SetTenor(tenor);

            var tradeRequest = new TradeRequest
            {
                Trade = trade
            };

            /*
             * for some reason tradeRequest.ApplyBinding(); cannot be called by the client sending the request
             * so weed need to have a way to maintain the state of the request when sending hence the ICustomFieldProcessor
             */

            var avroRequest = tradeRequest.ToAvroRecord(schema, new TradeRequestValueGetter());

            // assume we send the message on the wire, server receives and restores
            // the message using the same CustomFieldProcessor

            var receivedTradeRequest =
                avroRequest.FromAvroRecord <TradeRequest>(customValueSetter: new TradeRequestValueSetter());

            receivedTradeRequest.ApplyBinding();

            // test if the receive expiry date is 3 months from now
            Assert.AreEqual(((Vanilla)receivedTradeRequest.Trade).ExpiryDate.Date, DateTime.Now.AddMonths(3).Date);
        }
예제 #9
0
        static void Main(string[] args)
        {
            IceCreamComponent my = new Chocolate();

            my = new CherriesDecorator(my);

            IceCreamComponent your = new Vanilla();

            your = new StrawberriesDecorator(your);

            IceCreamComponent his = new Chocolate();

            his = new StrawberriesDecorator(his);
            his = new CherriesDecorator(his);

            Console.WriteLine("My icecream: {0} and it costs ${1}.", my.getDescription(), my.CalculateCost());
            Console.WriteLine("Your icecream: {0} and it costs ${1}.", your.getDescription(), your.CalculateCost());
            Console.WriteLine("His icecream: {0} and it costs ${1}.", his.getDescription(), his.CalculateCost());
        }
예제 #10
0
            public IceCream IceCreamFactory(IceCreamTypes iceCreamTypes)
            {
                IceCream iceCream = null;

                switch (iceCreamTypes)
                {
                case IceCreamTypes.Strawberry:
                    iceCream = new Strawberry();
                    break;

                case IceCreamTypes.Chocolate:
                    iceCream = new Chocolate();
                    break;

                case IceCreamTypes.Vanilla:
                    iceCream = new Vanilla();
                    break;
                }
                return(iceCream);
            }
예제 #11
0
        public ColorPalette(ConfigOptions config)
        {
            var configFolder = config.ConfigurationFolder;

            _configFile = Path.Combine(configFolder, FileName);
            _localPath  = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            SchemaSet   = SetXmlSchema(config.XmlValidation);

            Xdoc    = XDocument.Load(_configFile);
            Vanilla = Xdoc.Descendants().First(key => (string)key.Attribute("name") == ".Vanilla");
            Build   = Vanilla.AttributeOrEmpty("build").Value;

            if (config.BackupConfiguration)
            {
                BackupConfiguration(configFolder, _configFile);
            }

            ColorCount = Vanilla.Descendants().Count(key => (string)key.Attribute("name") == "Colors");

            InstalledThemes = ColorCount == 0 ? new List <string>() : GetInstalledPalettes();
        }
예제 #12
0
    static void Main(string[] args)
    {
        var inputs = new Dictionary <int, string>()
        {
            { 2, "second" },
            { 3, "Fizz" },
            { 5, "Buzz" },
            { 6, "Sixth" }
        };

        Console.WriteLine("Vanilla:");
        Console.WriteLine();
        Vanilla.FizzBuzz(inputs, Console.Out);
        Console.WriteLine();

        Console.WriteLine("Linq-y:");
        Console.WriteLine();
        Linqy.FizzBuzz(inputs, Console.Out);

        Console.ReadLine();
    }
예제 #13
0
        private static void Decorator_Pattern()
        {
            // TODO attaches additional responsibilities to an object dynamically
            // TODO provide a flexibility alternative to subclassing for extending functionality => To Espresso we attache Caramel
            //                                                                              => To Espresso and Caramel we attache Vanilla

            Console.WriteLine(nameof(Constants.Espresso_Cost) + " {0}", Constants.Espresso_Cost);
            Console.WriteLine(nameof(Constants.Caramel_Cost) + " {0}", Constants.Caramel_Cost);
            Console.WriteLine(nameof(Constants.Vanilla_Cost) + " {0}", Constants.Vanilla_Cost);


            var caramelDecorator = new Caramel(new Espresso());
            var totalCaramelCost = caramelDecorator.Cost();
            var vanillaDecorator = new Vanilla(caramelDecorator);
            var totalVanillaCost = vanillaDecorator.Cost();

            Console.WriteLine("Total cost = [ new Caramel(new Espresso()).Cost() ] = {0}", totalCaramelCost);
            Console.WriteLine("Total cost = [ new Vanilla(new Caramel(new Espresso())).Cost() ] = {0}", totalVanillaCost);

            Console.WriteLine("\n");
        }
예제 #14
0
        public static void CallDecoratorPattern()
        {
            IceCream iceCreamChocolate = new Chocolate();

            iceCreamChocolate = new Sprinkle(iceCreamChocolate);
            iceCreamChocolate = new Fudge(iceCreamChocolate);

            Console.WriteLine("Chocolate Ice Cream with Sprinkles, Fudge = " + iceCreamChocolate.Cost().ToString("C"));

            IceCream iceCreamVanilla = new Vanilla();

            iceCreamVanilla = new Sprinkle(iceCreamVanilla);
            iceCreamVanilla = new Fudge(iceCreamVanilla);
            iceCreamVanilla = new Caramel(iceCreamVanilla);
            iceCreamVanilla = new WhipCream(iceCreamVanilla);
            iceCreamVanilla = new WaffleCone(iceCreamVanilla);

            Console.WriteLine("Vanilla Ice Cream with Sprinkles, Fudge, Caramel, WhipCream, WaffleCone = " + iceCreamVanilla.Cost().ToString("C"));

            Console.ReadKey();
        }
예제 #15
0
 /// <summary>
 /// Initializes static members of the <see cref="OmniClassTaxonomy"/> class.
 /// </summary>
 static OmniClassTaxonomy()
 {
     Vanilla     = OmniClassTaxonomyItem.ReadFromResource("OmniClassTaxonomy_Vanilla.txt");
     FoodService = OmniClassTaxonomyItem.ReadFromResource("OmniClassTaxonomy_FoodService.txt");
     Merged      = Vanilla.Union(FoodService).Distinct().OrderBy(i => i.Id).ToList();
 }
예제 #16
0
        //Below is used to get the int value for X amounts the user selects for the condiments
        public ActionResult display(string Coffee, int?Decorator1, int?Decorator2, int?Decorator3, int?Decorator4, int?Decorator5, int?Decorator6, int?Decorator7, int?Decorator8, int?Decorator9, int?Decorator10)
        {
            //assign base coffees different orders
            CoffeeNull  anOrder0 = new CoffeeNull();
            ViennaRoast anOrder  = new ViennaRoast();
            Espresso    anOrder2 = new Espresso();
            Columbian   anOrder3 = new Columbian();
            Decaf       anOrder4 = new Decaf();
            FrenchRoast anOrder5 = new FrenchRoast();

            //gets price of condiment under an empty order so you just get condiments price
            PumpkinSpice addon1  = new PumpkinSpice(anOrder0);
            Milk         addon2  = new Milk(anOrder0);
            Soy          addon3  = new Soy(anOrder0);
            CaramelSyrup addon4  = new CaramelSyrup(anOrder0);
            EspressoShot addon5  = new EspressoShot(anOrder0);
            Mocha        addon6  = new Mocha(anOrder0);
            SkimMilk     addon7  = new SkimMilk(anOrder0);
            Vanilla      addon8  = new Vanilla(anOrder0);
            WhipCream    addon9  = new WhipCream(anOrder0);
            Cinnamon     addon10 = new Cinnamon(anOrder0);


            //declare condiments
            double price        = 0;
            double pumpkinSpice = 0;
            double milk         = 0;
            double soy          = 0;
            double cinnamon     = 0;
            double whipcream    = 0;
            double vanilla      = 0;
            double skimmilk     = 0;
            double caramelsyrup = 0;
            double espressoshot = 0;
            double mocha        = 0;

            //declare condiments variable description
            string spumpkinSpice = "";
            string smilk         = "";
            string ssoy          = "";
            string svanilla      = "";
            string swhipcream    = "";
            string sespressoshot = "";
            string smocha        = "";
            string scaramelsyrup = "";
            string sskimmilk     = "";
            string scinnamon     = "";

            //convert users  input numbers for X amounts of condiments to variables we can use here
            int decorator1  = Decorator1 ?? default(int);
            int decorator2  = Decorator2 ?? default(int);
            int decorator3  = Decorator3 ?? default(int);
            int decorator4  = Decorator4 ?? default(int);
            int decorator5  = Decorator5 ?? default(int);
            int decorator6  = Decorator6 ?? default(int);
            int decorator7  = Decorator7 ?? default(int);
            int decorator8  = Decorator8 ?? default(int);
            int decorator9  = Decorator9 ?? default(int);
            int decorator10 = Decorator10 ?? default(int);


            //gets the cost of the condiment if it is selected * X amount and a Coffee is checked
            if (decorator1 > 0 && Coffee == "FrenchRoast" || Coffee == "ViennaRoast" || Coffee == "Espresso" || Coffee == "Columbian" || Coffee == "Decaf")
            {
                pumpkinSpice = addon1.GetCost() * decorator1;
                price        = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                //repeats the string in qoutes based on users input amount
                spumpkinSpice = String.Concat(Enumerable.Repeat("PumpkinSpice ", decorator1));
            }



            if (decorator2 > 0 && Coffee == "ViennaRoast" || decorator2 > 0 && Coffee == "FrenchRoast" || decorator2 > 0 && Coffee == "Espresso" || decorator2 > 0 && Coffee == "Columbian" || decorator2 > 0 && Coffee == "Decaf")
            {
                milk  = addon2.GetCost() * decorator2;
                price = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                smilk = String.Concat(Enumerable.Repeat("Milk ", decorator2));
            }

            if (decorator3 > 0 && Coffee == "ViennaRoast" || decorator3 > 0 && Coffee == "FrenchRoast" || decorator3 > 0 && Coffee == "Espresso" || decorator3 > 0 && Coffee == "Columbian" || decorator3 > 0 && Coffee == "Decaf")
            {
                soy   = addon3.GetCost() * decorator3;
                price = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                ssoy = String.Concat(Enumerable.Repeat("Soy ", decorator3));
            }


            if (decorator4 > 0 && Coffee == "ViennaRoast" || decorator4 > 0 && Coffee == "FrenchRoast" || decorator4 > 0 && Coffee == "Espresso" || decorator4 > 0 && Coffee == "Columbian" || decorator4 > 0 && Coffee == "Decaf")
            {
                caramelsyrup = addon4.GetCost() * decorator4;
                price        = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                scaramelsyrup = String.Concat(Enumerable.Repeat("CaramelSyrup ", decorator4));
            }


            if (decorator5 > 0 && Coffee == "ViennaRoast" || decorator5 > 0 && Coffee == "FrenchRoast" || decorator5 > 0 && Coffee == "Espresso" || decorator5 > 0 && Coffee == "Columbian" || decorator5 > 0 && Coffee == "Decaf")
            {
                espressoshot = addon5.GetCost() * decorator5;
                price        = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                sespressoshot = String.Concat(Enumerable.Repeat("EspressoShot ", decorator5));
            }



            if (decorator6 > 0 && Coffee == "ViennaRoast" || decorator6 > 0 && Coffee == "FrenchRoast" || decorator6 > 0 && Coffee == "Espresso" || decorator6 > 0 && Coffee == "Columbian" || decorator6 > 0 && Coffee == "Decaf")
            {
                mocha = addon6.GetCost() * decorator6;
                price = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                smocha = String.Concat(Enumerable.Repeat("Mocha ", decorator6));
            }


            if (decorator7 > 0 && Coffee == "ViennaRoast" || decorator7 > 0 && Coffee == "FrenchRoast" || decorator7 > 0 && Coffee == "Espresso" || decorator7 > 0 && Coffee == "Columbian" || decorator7 > 0 && Coffee == "Decaf")
            {
                skimmilk = addon7.GetCost() * decorator7;
                price    = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                sskimmilk = String.Concat(Enumerable.Repeat("SkimMilk ", decorator7));
            }


            if (decorator8 > 0 && Coffee == "ViennaRoast" || decorator8 > 0 && Coffee == "FrenchRoast" || decorator8 > 0 && Coffee == "Espresso" || decorator8 > 0 && Coffee == "Columbian" || decorator8 > 0 && Coffee == "Decaf")
            {
                vanilla = addon8.GetCost() * decorator8;
                price   = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                svanilla = String.Concat(Enumerable.Repeat("Vanilla ", decorator8));
            }


            if (decorator9 > 0 && Coffee == "ViennaRoast" || decorator9 > 0 && Coffee == "FrenchRoast" || decorator9 > 0 && Coffee == "Espresso" || decorator9 > 0 && Coffee == "Columbian" || decorator9 > 0 && Coffee == "Decaf")
            {
                whipcream = addon9.GetCost() * decorator9;
                price     = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                swhipcream = String.Concat(Enumerable.Repeat("WhipCream ", decorator9));
            }

            if (decorator10 > 0 && Coffee == "ViennaRoast" || decorator10 > 0 && Coffee == "FrenchRoast" || decorator10 > 0 && Coffee == "Espresso" || decorator10 > 0 && Coffee == "Columbian" || decorator10 > 0 && Coffee == "Decaf")
            {
                cinnamon = addon10.GetCost() * decorator10;
                price    = anOrder.GetCost() + pumpkinSpice + milk + soy + mocha + espressoshot + vanilla + skimmilk + whipcream + cinnamon + caramelsyrup;

                scinnamon = String.Concat(Enumerable.Repeat("Cinnamon ", decorator10));
            }



            //display for if coffee is selected without any addons
            if (decorator1 == 0 && decorator2 == 0 && decorator3 == 0 && decorator4 == 0 && decorator5 == 0 && decorator6 == 0 && decorator7 == 0 && decorator8 == 0 && decorator9 == 0 && decorator10 == 0)
            {
                price = anOrder.GetCost();
            }

            //declare viewbags to display data
            ViewBag.CofeeNull   = anOrder0;
            ViewBag.ViennaRoast = anOrder;
            ViewBag.espresso    = anOrder2;
            ViewBag.columbian   = anOrder3;
            ViewBag.Decaf       = anOrder4;
            ViewBag.FrenchRoast = anOrder5;


            ViewBag.price        = price;
            ViewBag.pumpkinSpice = spumpkinSpice;
            ViewBag.milk         = smilk;
            ViewBag.soy          = ssoy;
            ViewBag.caramelsyrup = scaramelsyrup;
            ViewBag.espressoshot = sespressoshot;
            ViewBag.mocha        = smocha;
            ViewBag.skimMilk     = sskimmilk;
            ViewBag.vanilla      = svanilla;
            ViewBag.whipcream    = swhipcream;
            ViewBag.cinnamon     = scinnamon;


            //if coffee is selected, return its name, and not all coffee names
            if (Coffee == "Columbian")
            {
                ViewBag.columbian = anOrder3;
            }
            else
            {
                ViewBag.columbian = anOrder0;
            }
            if (Coffee == "Decaf")
            {
                ViewBag.Decaf = anOrder4;
            }
            else
            {
                ViewBag.Decaf = anOrder0;
            }
            if (Coffee == "Espresso")
            {
                ViewBag.espresso = anOrder2;
            }
            else
            {
                ViewBag.espresso = anOrder0;
            }
            if (Coffee == "FrenchRoast")
            {
                ViewBag.FrenchRoast = anOrder5;
            }
            else
            {
                ViewBag.FrenchRoast = anOrder0;
            }
            if (Coffee == "ViennaRoast")
            {
                ViewBag.ViennaRoast = anOrder;
            }
            else
            {
                ViewBag.ViennaRoast = anOrder0;
            }


            return(View());
        }
예제 #17
0
    protected override Character CreateCopy()
    {
        Vanilla copy = new Vanilla();

        return(copy);
    }