/// <summary> /// Read XML file containing definitions to in-memory object for later use by .GetTemplate() /// </summary> /// <param name="xmlFile">which file to load templates from</param> public static void Load(string xmlFile) { if (xmlFile == null || xmlFile.Length < 1) { throw new DuryTools.ErrorHandler("TemplateLoader: xmlFile is blank or null"); } Templates = new NodeTemplateCollection(); xmlFile = SFGlobal.BaseDirectory + xmlFile; try { System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); xd.Load(xmlFile); foreach (XmlNode x in xd["nodeTypes"]) { NodeTemplate n = new NodeTemplate(); n.ID = int.Parse(x.Attributes["id"].Value); n.Name = x.Attributes["name"].Value; n.SiteTemplate = x.Attributes["siteTemplate"].Value; n.AdminTemplate = x.Attributes["adminTemplate"].Value; n.PublishSP = (x.Attributes["publishSP"] != null) ? x.Attributes["publishSP"].Value : ""; Templates.Add(n); } } catch (Exception e) { throw new DuryTools.ErrorHandler("Problem parsing XML file.. check xml syntax or file: " + xmlFile, e); } }
public void Add(NodeTemplate n) { List.Add(n); }