Beispiel #1
0
        /// <summary>
        /// Creates project details for given project from xml file
        /// </summary>
        /// <param name="projNode"></param>
        /// <returns></returns>
        private ProjectDetails CreateProjectDetails(XmlNode projNode)
        {
            var projectDetails = new ProjectDetails
            {
                LanguagesForPoject = new Dictionary <string, bool>(),
                ShouldBeExported   = false
            };
            var projectFolderPath = Empty;
            var doc = new XmlDocument();

            try
            {
                var selectSingleNode = projNode.SelectSingleNode("ProjectInfo");
                if (selectSingleNode?.Attributes != null)
                {
                    projectDetails.ProjectName = selectSingleNode.Attributes["Name"].Value;
                }
                if (projNode.Attributes != null)
                {
                    projectFolderPath = projNode.Attributes["ProjectFilePath"].Value;
                }
                if (Path.IsPathRooted(projectFolderPath))
                {
                    projectDetails.ProjectPath = projectFolderPath;                     //location outside standard project place
                }
                else
                {
                    var projectsFolderPath = _projectXmlPath.Substring
                                                 (0, _projectXmlPath.LastIndexOf(@"\", StringComparison.Ordinal) + 1);
                    projectDetails.ProjectPath = projectsFolderPath + projectFolderPath;
                }
                var projectStatus = ProjectInformation.GetProjectStatus(projectDetails.ProjectPath);

                doc.Load(projectDetails.ProjectPath);

                var projectLanguages = Help.LoadLanguageDirections(doc);

                SetLanguagesForProject(projectDetails, projectLanguages);

                projectDetails.Status = projectStatus;
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"CreateProjectDetails method: {ex.Message}\n {ex.StackTrace}");
            }
            return(projectDetails);
        }