static private FolderType MakeFolder(JadeData.Workspace.IFolder folder) { FolderType result = new FolderType(); result.Name = folder.Name; FolderType[] subs = new FolderType[folder.Folders.Count]; for (int i = 0; i < folder.Folders.Count; i++) { subs[i] = MakeFolder(folder.Folders[i]); } result.Folders = subs; List<JadeData.Workspace.ProjectItem> projTemps = new List<JadeData.Workspace.ProjectItem>(); foreach (JadeData.Workspace.ProjectItem proj in folder.Items.OfType<JadeData.Workspace.ProjectItem>()) { projTemps.Add(proj); } ProjectType[] projs = new ProjectType[projTemps.Count]; for(int i=0;i<projTemps.Count;i++) { projs[i] = MakeProject(projTemps[i]); } result.Projects = projs; return result; }
private static JadeData.Workspace.IFolder MakeFolder(string workspaceDir, FolderType xml) { JadeData.Workspace.IFolder result = new JadeData.Workspace.Folder(xml.Name); foreach (FolderType f in xml.Folders) { result.AddFolder(MakeFolder(workspaceDir, f)); } foreach (ProjectType p in xml.Projects) { result.AddProject(MakeProject(workspaceDir, p)); } return result; }
static public string Write(JadeData.Workspace.IWorkspace workspace, string path) { string workspaceDir = System.IO.Path.GetDirectoryName(path); JadeData.Workspace.IFolder folder = workspace; WorkspaceType result = new WorkspaceType(); result.Name = workspace.Name; FolderType[] subs = new FolderType[folder.Folders.Count]; for (int i = 0; i < folder.Folders.Count; i++) { subs[i] = MakeFolder(folder.Folders[i], workspaceDir); } result.Folders = subs; List<JadeData.Workspace.ProjectItem> projTemps = new List<JadeData.Workspace.ProjectItem>(); foreach (JadeData.Workspace.ProjectItem proj in folder.Items.OfType<JadeData.Workspace.ProjectItem>()) { projTemps.Add(proj); } ProjectType[] projs = new ProjectType[projTemps.Count]; for (int i = 0; i < projTemps.Count; i++) { projs[i] = MakeProject(projTemps[i], workspaceDir); } result.Projects = projs; System.Xml.XmlDocument doc = new XmlDocument(); System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(result.GetType()); System.IO.TextWriter stream = new System.IO.StreamWriter(path); try { serializer.Serialize(stream, result); stream.Close(); return ""; } catch { throw; } finally { stream.Close(); stream.Dispose(); } }