public static IContentPart Instantiate(string id, string typecode, IColumn parentColumn) { switch (typecode.Trim().ToLowerInvariant()) { case "columncontainer": ColumnContainer container = new ColumnContainer(parentColumn); container.Id = id; return container; case "column": Column col = new Column(); col.Id = id; return col; case "htmlpart": Html htmlpart = new Html(); htmlpart.Id = id; return htmlpart; case "image": Image img = new Image(); return img; } return null; }
public void DeserializeFromXml(string xml) { XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(xml); this.Columns.Clear(); XmlNode spacerNode = xdoc.SelectSingleNode("/part/spacerabove"); if (spacerNode != null) { bool spacerOut = false; if (bool.TryParse(spacerNode.InnerText, out spacerOut)) { this.SpacerAbove = spacerOut; } } XmlNodeList columnNodes = xdoc.SelectNodes("/part/columns/part"); if (columnNodes != null) { foreach (XmlNode node in columnNodes) { XmlNode idNode = node.SelectSingleNode("id"); if (idNode != null) { Column col = new Column(); col.Id = idNode.InnerText; col.DeserializeFromXml(node.OuterXml); this.Columns.Add(col); } } } }