private static Folder DeserialiseFolder(XmlNode folderNode) { Folder folder = new Folder(); folder.ID = FolderIdCounter++; folder.Name = folderNode.Attributes["name"].Value; folder.Iterator = (IteratorTypes)Enum.Parse(typeof(IteratorTypes), folderNode.Attributes["iterator"].Value, true); foreach (XmlNode fileNode in folderNode.SelectNodes("file")) { File file = DeserialiseFile(fileNode); file.ParentFolder = folder; folder.Files.Add(file); } foreach (XmlNode fileNode in folderNode.SelectNodes("static-file")) { StaticFile file = DeserialiseStaticFile(fileNode); file.ParentFolder = folder; folder.StaticFiles.Add(file); } foreach (XmlNode subFolderNode in folderNode.SelectNodes("folder")) { Folder subFolder = DeserialiseFolder(subFolderNode); subFolder.ParentFolder = folder; folder.Folders.Add(subFolder); } return(folder); }
private static TemplateProject DeserialiseTemplateProject(XmlNode templateProjectNode) { TemplateProject project = new TemplateProject(); var delimiterAtt = templateProjectNode.Attributes["delimiter-style"]; if (delimiterAtt != null) { project.Delimiter = (TemplateProject.DelimiterTypes)Enum.Parse(typeof(TemplateProject.DelimiterTypes), delimiterAtt.Value, true); } foreach (XmlNode folderNode in templateProjectNode.SelectNodes("folder")) { Folder subFolder = DeserialiseFolder(folderNode); subFolder.ParentFolder = project.OutputFolder; project.OutputFolder.Folders.Add(subFolder); } foreach (XmlNode fileNode in templateProjectNode.SelectNodes("file")) { File file = DeserialiseFile(fileNode); file.ParentFolder = project.OutputFolder; project.OutputFolder.Files.Add(file); } foreach (XmlNode fileNode in templateProjectNode.SelectNodes("static-file")) { StaticFile file = DeserialiseStaticFile(fileNode); file.ParentFolder = project.OutputFolder; project.OutputFolder.StaticFiles.Add(file); } return(project); }
private static void SerialiseStaticFile(StaticFile file, XmlWriter writer) { writer.WriteStartElement("static-file"); writer.WriteAttributeString("id", file.Id.ToString()); writer.WriteAttributeString("name", file.Name); writer.WriteAttributeString("iterator", file.Iterator.ToString()); writer.WriteAttributeString("resource-name", file.ResourceName); writer.WriteEndElement(); }
private static void SerialiseStaticFile(StaticFile file, XmlWriter writer) { writer.WriteStartElement("static-file"); writer.WriteAttributeString("id", file.Id.ToString()); writer.WriteAttributeString("name", file.Name); writer.WriteAttributeString("iterator", file.Iterator.ToString()); writer.WriteAttributeString("resource-name", file.ResourceName); writer.WriteEndElement(); }
private static StaticFile DeserialiseStaticFile(XmlNode fileNode) { StaticFile file = new StaticFile(); file.Id = int.Parse(fileNode.Attributes["id"].Value); file.Name = fileNode.Attributes["name"].Value; file.Iterator = (IteratorTypes)Enum.Parse(typeof(IteratorTypes), fileNode.Attributes["iterator"].Value, true); file.ResourceName = fileNode.Attributes["resource-name"].Value; return(file); }
private static StaticFile DeserialiseStaticFile(XmlNode fileNode) { StaticFile file = new StaticFile(); file.Id = int.Parse(fileNode.Attributes["id"].Value); file.Name = fileNode.Attributes["name"].Value; file.Iterator = (IteratorTypes)Enum.Parse(typeof(IteratorTypes), fileNode.Attributes["iterator"].Value, true); file.ResourceName = fileNode.Attributes["resource-name"].Value; return file; }