public static Project Load(string path = null) { var connector = new FileConnectorXML(); connector.FileName = path; if (connector.FileName == null) { var result = connector.CheckFilePath(FileOperate.Read); if (result == false) { return(null); } } var proj = connector.ReadFile().FirstOrDefault(); if (proj == null) { return(null); } var proj2 = new Project(); proj.DictCopyTo(proj2); proj2.SavePath = connector.FileName; return(proj2); }
public static Project Load(string path = null) { var connector = new FileConnectorXML(); connector.FileName = path; if (connector.FileName == null) { var result = connector.CheckFilePath(FileOperate.Read); if (result == false) { return(null); } } else { if (!File.Exists(connector.FileName)) { XLogSys.Print.Error($"文件{connector.FileName}不存在"); return(null); } } var proj = connector.ReadFile().FirstOrDefault(); if (proj == null) { return(null); } var proj2 = new Project(); proj.DictCopyTo(proj2); proj2.SavePath = connector.FileName; return(proj2); }
public static Project LoadProject(string path) { if (File.Exists(path) == false) { throw new Exception("当前工程文件的路径不存在,生成新工程"); } var xml = new FileConnectorXML { FileName = path }; var r = xml.ReadFile().FirstOrDefault(); var project = new Project(); if (r != null) { project.DictDeserialize(r.DictSerialize()); } return(project); }
public static Project Load(string path = null) { var connector = new FileConnectorXML(); connector.FileName = path; if (connector.FileName == null) { var result = connector.CheckFilePath(FileOperate.Read); if (result == false) { return(null); } } else { if (!File.Exists(connector.FileName)) { XLogSys.Print.Error(string.Format(GlobalHelper.Get("key_334"), connector.FileName)); return(null); } } var ext = Path.GetExtension(connector.FileName); if (ext != null && ext.Contains("hproj")) { connector.IsZip = true; } var projfile = connector.ReadFile().FirstOrDefault(); if (projfile == null) { return(null); } var proj = new Project(); DocumentToProject(projfile, proj); proj.SavePath = connector.FileName; return(proj); }
public static async Task <Project> LoadFromUrl(string url) { var resquest = await WebRequest.Create(url).GetResponseAsync(); var response = resquest.GetResponseStream(); var fileConnector = new FileConnectorXML(); var proj = new Project(); ControlExtended.SafeInvoke(() => { var docs = fileConnector.ReadFile(response, url.EndsWith("hproj"), null); if (docs.Any() == false) { throw new Exception("TODO"); } var first = docs.FirstOrDefault(); DocumentToProject(first, proj); }, LogType.Info, GlobalHelper.Get("key_307")); return(proj); }