Exemplo n.º 1
0
        private void AddProjectItems([NotNull] ResourceEntity entity, [NotNull] ResourceLanguage neutralLanguage, [NotNull] string languageFileName)
        {
            DteProjectFile projectFile = null;

            var projectItems = (neutralLanguage.ProjectFile as DteProjectFile)?.ProjectItems;

            if (projectItems == null)
            {
                entity.AddLanguage(new ProjectFile(languageFileName, entity.Container.SolutionFolder ?? string.Empty, entity.ProjectName, null));
                return;
            }

            foreach (var neutralLanguageProjectItem in projectItems)
            {
                var collection        = neutralLanguageProjectItem.Collection;
                var projectItem       = collection.AddFromFile(languageFileName);
                var containingProject = projectItem.ContainingProject;
                var projectName       = containingProject.Name;
                if (projectFile == null)
                {
                    projectFile = new DteProjectFile(_exportProvider.GetExportedValue <DteSolution>(), languageFileName, projectName, containingProject.UniqueName, projectItem);
                }
                else
                {
                    projectFile.AddProject(projectName, projectItem);
                }
            }

            if (projectFile != null)
            {
                entity.AddLanguage(projectFile);
            }
        }
Exemplo n.º 2
0
        private void AddProjectItems(ResourceEntity entity, ResourceLanguage neutralLanguage, string languageFileName)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            DteProjectFile?projectFile = null;

            var projectItems = (neutralLanguage.ProjectFile as DteProjectFile)?.ProjectItems;

            if (projectItems == null)
            {
                entity.AddLanguage(new ProjectFile(languageFileName, entity.Container.SolutionFolder ?? string.Empty, entity.ProjectName, null));
                return;
            }

            foreach (var neutralLanguageProjectItem in projectItems)
            {
                var collection        = neutralLanguageProjectItem.Collection;
                var projectItem       = collection.AddFromFile(languageFileName);
                var containingProject = projectItem.ContainingProject;
                var projectName       = containingProject.Name;
                if (projectFile == null)
                {
                    var solution = _exportProvider.GetExportedValue <DteSolution>();

                    projectFile = new DteProjectFile(solution, solution.SolutionFolder, languageFileName, projectName, containingProject.UniqueName, projectItem);
                }
                else
                {
                    projectFile.AddProject(projectName, projectItem);
                }
            }

            if (projectFile != null)
            {
                entity.AddLanguage(projectFile);
            }
        }