Example #1
0
        static private ProjectType MakeProject(JadeCore.Workspace.ProjectItem proj, string workspaceDir)
        {
            ProjectType result = new ProjectType();

            //Convert to relative path for storage in workspace
            result.Path = JadeUtils.IO.PathUtils.CalculateRelativePath(workspaceDir + @"\", proj.Path.Str);
            Persistence.Project.Writer.Write(proj, proj.Path.Str);
            return result;
        }
Example #2
0
 private static JadeCore.Project.IProject MakeProject(string workspaceDir, ProjectType xml, IFileService fileService)
 {
     string path = xml.Path;
     if (System.IO.Path.IsPathRooted(path) == false)
     {
         //Convert from relative path stored in workspace xml file
         path = JadeUtils.IO.PathUtils.CombinePaths(workspaceDir, path);
     }
     return Persistence.Project.Reader.Read(path, fileService);
 }
Example #3
0
        static private FolderType MakeFolder(JadeCore.Workspace.IFolder folder, string workspaceDir)
        {
            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], workspaceDir);
            }
            result.Folders = subs;

            List<JadeCore.Workspace.ProjectItem> projTemps = new List<JadeCore.Workspace.ProjectItem>();
            foreach (JadeCore.Workspace.ProjectItem proj in folder.Items.OfType<JadeCore.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;

            return result;
        }
Example #4
0
        static public string Write(JadeCore.Workspace.IWorkspace workspace, string path)
        {
            string workspaceDir = System.IO.Path.GetDirectoryName(path);

            JadeCore.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<JadeCore.Workspace.ProjectItem> projTemps = new List<JadeCore.Workspace.ProjectItem>();
            foreach (JadeCore.Workspace.ProjectItem proj in folder.Items.OfType<JadeCore.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();
            }
        }