public void LoadFromXml(XElement xElement) { CatalogItems = new List<CatalogItem>(); foreach (XElement catalogElements in xElement.Elements("CatalogItems")) { foreach (XElement catalogItemElement in catalogElements.Elements("CatalogItem") ) { CatalogItem newItem = new CatalogItem(); newItem.LoadFromXml(catalogItemElement); CatalogItems.Add(newItem); } } foreach (XElement catalogElements in xElement.Elements("BoxedItems")) { foreach (XElement catalogElement in catalogElements.Elements("BoxedItem")) { BoxedItem newItem = new BoxedItem(); newItem.LoadFromXml(catalogElement); BoxedItems.Add(newItem); } } foreach (XElement catalogElements in xElement.Elements("VolumeItems")) { foreach (XElement catalogElement in catalogElements.Elements("VolumeItem")) { VolumeItem newItem = new VolumeItem(); newItem.LoadFromXml(catalogElement); VolumeItems.Add(newItem); } } }
CatalogItem CreateNewCatalogItem() { CatalogItem catalogItem = new CatalogItem(); if (rdoCatalogBox.Checked) { catalogItem = new BoxedItem(); } else if (rdoCatalogVolume.Checked) { catalogItem = new VolumeItem(); } else { catalogItem = new CatalogItem(); } return catalogItem; }