static void Write(VisualDProject prj, XmlWriter x) { x.WriteStartDocument(); x.WriteStartElement("DProject"); x.WriteElementString("ProjectGuid", prj.ItemId); foreach (VisualDPrjConfig config in prj.Configurations) { x.WriteStartElement("Config"); x.WriteAttributeString("name", config.Name); x.WriteAttributeString("platform", config.Platform); foreach (var kv in config.Properties) { x.WriteElementString(kv.Key, kv.Value); } x.WriteEndElement(); } //TODO: Files x.WriteEndDocument(); x.Close(); }
public static VisualDProject Read(FilePath file, XmlReader x) { var prj = new VisualDProject(); prj.FileName = file; var folderStack = new Stack <string>(); string path; while (x.Read()) { if (x.NodeType == XmlNodeType.Element) { switch (x.LocalName) { case "ProjectGuid": prj.ItemIdToAssign = x.ReadString(); break; case "Config": VisualDPrjConfig.ReadAndAdd(prj, x.GetAttribute("name"), x.GetAttribute("platform"), x.ReadSubtree()); break; case "Folder": if (folderStack.Count == 0) { // Somehow, the very root Folder node gets merely ignored..somehow folderStack.Push(string.Empty); break; } folderStack.Push(Building.ProjectBuilder.EnsureCorrectPathSeparators(x.GetAttribute("name") ?? string.Empty)); path = GetPath(folderStack); if (!string.IsNullOrWhiteSpace(path)) { prj.AddDirectory(path); } break; case "File": var filePath = Building.ProjectBuilder.EnsureCorrectPathSeparators(x.GetAttribute("path")); //TODO: Custom tools that are executed right before building..gosh! if (!string.IsNullOrWhiteSpace(filePath) && !string.IsNullOrWhiteSpace(path = GetPath(folderStack, filePath))) { prj.AddFile(Path.IsPathRooted(path) ? path : prj.BaseDirectory.Combine(path).ToString(), BuildAction.Compile); } break; } } if (x.NodeType == XmlNodeType.EndElement && x.LocalName == "Folder") { folderStack.Pop(); } } return(prj); }
public static VisualDPrjConfig ReadAndAdd(VisualDProject prj, string name, string platform, XmlReader x) { var c = prj.AddNewConfiguration (name ?? "Unknown") as VisualDPrjConfig; c.Platform = platform; while (x.Read ()) { var n = x.LocalName; if (string.IsNullOrWhiteSpace (n) || n == "Config") continue; var content = x.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace (content)) c.Properties [n] = content; } return c; }
public object ReadFile(FilePath file, Type expectedType, IProgressMonitor monitor) { VisualDProject prj = null; using (var s = File.OpenText(file)) using (var r = new XmlTextReader(s)) prj = Read(file, r); if (typeof(Project).IsSubclassOf(expectedType)) { return(prj); } if (typeof(Solution).IsSubclassOf(expectedType)) { var sln = new Solution(); sln.Name = prj.Name; sln.RootFolder.AddItem(prj); return(sln); } return(prj); }
public static VisualDPrjConfig ReadAndAdd(VisualDProject prj, string name, string platform, XmlReader x) { var c = prj.AddNewConfiguration(name ?? "Unknown") as VisualDPrjConfig; c.Platform = platform; while (x.Read()) { var n = x.LocalName; if (string.IsNullOrWhiteSpace(n) || n == "Config") { continue; } var content = x.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(content)) { c.Properties [n] = content; } } return(c); }
public VisualDProjectReferenceCollection(VisualDProject prj) : base(prj) { }
static void Write(VisualDProject prj, XmlWriter x) { x.WriteStartDocument(); x.WriteStartElement("DProject"); x.WriteElementString("ProjectGuid", prj.ItemId); foreach (VisualDPrjConfig config in prj.Configurations) { x.WriteStartElement("Config"); x.WriteAttributeString("name", config.Name); x.WriteAttributeString("platform", config.Platform); foreach (var kv in config.Properties) x.WriteElementString(kv.Key, kv.Value); x.WriteEndElement(); } //TODO: Files x.WriteEndDocument(); x.Close(); }
public static VisualDProject Read(FilePath file, XmlReader x) { var prj = new VisualDProject (); prj.FileName = file; var folderStack = new Stack<string>(); string path; while (x.Read()) { if (x.NodeType == XmlNodeType.Element) switch (x.LocalName) { case "ProjectGuid": prj.ItemIdToAssign = x.ReadString(); break; case "Config": VisualDPrjConfig.ReadAndAdd(prj, x.GetAttribute("name"), x.GetAttribute("platform"), x.ReadSubtree()); break; case "Folder": if (folderStack.Count == 0) { // Somehow, the very root Folder node gets merely ignored..somehow folderStack.Push(string.Empty); break; } folderStack.Push(Building.ProjectBuilder.EnsureCorrectPathSeparators(x.GetAttribute("name") ?? string.Empty)); path = GetPath(folderStack); if(!string.IsNullOrWhiteSpace(path)) prj.AddDirectory(path); break; case "File": var filePath = Building.ProjectBuilder.EnsureCorrectPathSeparators(x.GetAttribute("path")); //TODO: Custom tools that are executed right before building..gosh! if (!string.IsNullOrWhiteSpace(filePath) && !string.IsNullOrWhiteSpace(path = GetPath(folderStack, filePath))) prj.AddFile(Path.IsPathRooted(path) ? path : prj.BaseDirectory.Combine(path).ToString(), BuildAction.Compile); break; } if (x.NodeType == XmlNodeType.EndElement && x.LocalName == "Folder") folderStack.Pop(); } return prj; }
public VisualDProjectReferenceCollection (VisualDProject prj) : base(prj) { }