Example #1
0
        private static void FillData()
        {
            if (!_sweetGift.HasElements) return;

            foreach(var element in _sweetGift.Elements())
            {
                switch(element.Name.LocalName)
                {
                    case "Biscuit":
                        {
                            var biscuit = new Biscuit();
                            GetGiftComponentPart(biscuit, element);
                            GetChocolatePart(biscuit, element);
                            Gift.Add(biscuit);
                        }
                        break;
                    case "Candy":
                        {
                            var candy = new Candy();
                            GetGiftComponentPart(candy, element);
                            GetChocolatePart(candy, element);
                            Gift.Add(candy);
                        }
                        break;
                    case "ChocolateEgg":
                        {
                            var chocolateEgg = new ChocolateEgg();
                            GetGiftComponentPart(chocolateEgg, element);
                            GetChocolatePart(chocolateEgg, element);
                            var toyElement = element.Element("Toy");
                            if(toyElement != null)
                            {
                                var toy = new InediblePart();
                                var madeOf = toyElement.Element("MadeOf");
                                if (madeOf != null)
                                {
                                    toy.MadeOf = (InediblePartType)Enum.Parse(typeof(InediblePartType), madeOf.Value);
                                }
                                var toyWeight = toyElement.Element("Weight");
                                if(toyWeight != null)
                                {
                                    toy.Weight = (int)toyWeight;
                                }
                                chocolateEgg.Toy = toy;
                            }
                            Gift.Add(chocolateEgg);
                        }
                        break;
                    case "Lollipop":
                        {
                            var lollipop = new Lollipop();
                            GetGiftComponentPart(lollipop, element);
                            var stickElement = element.Element("Stick");
                            if (stickElement != null)
                            {
                                var stick = new InediblePart();
                                var madeOf = stickElement.Element("MadeOf");
                                if (madeOf != null)
                                {
                                    stick.MadeOf = (InediblePartType)Enum.Parse(typeof(InediblePartType), madeOf.Value);
                                }
                                var stickWeight = stickElement.Element("Weight");
                                if (stickWeight != null)
                                {
                                    stick.Weight = (int)stickWeight;
                                }
                                lollipop.Stick = stick;
                            }
                            Gift.Add(lollipop);
                        }
                        break;
                }
            }
        }
 public ChocolateEgg(int weight, int sugar, int chocolate, string name, string companyName, Wrapper wrapper, GiftComponentMakingType makingType, InediblePart toy)
     : base(weight, sugar, name, companyName, wrapper, makingType)
 {
     _chocolate = chocolate;
     _toy = toy;
 }
Example #3
0
 public Lollipop(int weight, int sugar, string name, string companyName, Wrapper wrapper, GiftComponentMakingType makingType, InediblePart stick)
     : base(weight, sugar, name, companyName, wrapper, makingType)
 {
     _stick = stick;
 }