public void MenuItem_FromXML_ValidObject()
 {
     var mi = new MenuItem();
       string xmlIn = "<menu_item uid=\"1\" disabled=\"disabled\" special=\"special\">\r\n  <menu_item_name>item1</menu_item_name>\r\n  <menu_item_description>desc1</menu_item_description>\r\n  <menu_item_price>0</menu_item_price>\r\n</menu_item>";
       XElement xmlElem = XElement.Load(new StringReader(xmlIn));
       mi.FromXML(xmlElem);
       Assert.AreEqual("item1", mi.Name);
       Assert.AreEqual("desc1", mi.Description);
       Assert.AreEqual(0d, mi.Price);
       Assert.IsTrue(mi.Disabled);
       Assert.IsTrue(mi.Special);
       Assert.IsFalse(mi.Vegetarian);
 }
Exemple #2
0
        public override void FromXML(XElement xml)
        {
            this.Name = (string) xml.Attribute("name");
              this.Description = (string)xml.Element("menu_group_description");
              this.UID = (string)xml.Attribute("uid");

              XElement itemsElement = xml.Element("menu_items");
              if (itemsElement != null) {
            this.Items = new ObservableCollection<MenuItem>();
            foreach (XElement itemElement in itemsElement.Elements()) {
              var mi = new MenuItem();
              mi.Group = this;
              mi.FromXML(itemElement);
              this.Items.Add(mi);
            }
              }
        }