当前位置: 首页>>代码示例>>C#>>正文


C# Project.RemoveDocument方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.Project.RemoveDocument方法的典型用法代码示例。如果您正苦于以下问题:C# Project.RemoveDocument方法的具体用法?C# Project.RemoveDocument怎么用?C# Project.RemoveDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.Project的用法示例。


在下文中一共展示了Project.RemoveDocument方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveNonExistingDocuments

        private static Solution RemoveNonExistingDocuments(Project project)
        {
            foreach (var documentId in project.DocumentIds.ToArray())
            {
                var document = project.GetDocument(documentId);
                if (!File.Exists(document.FilePath))
                {
                    Log.Message("Document doesn't exist on disk: " + document.FilePath);
                    project = project.RemoveDocument(documentId);
                }
            }

            return project.Solution;
        }
开发者ID:akrisiun,项目名称:SourceBrowser,代码行数:14,代码来源:SolutionGenerator.cs

示例2: DisambiguateSameNameLinkedFiles

        /// <summary>
        /// If there are two linked files both outside the project cone, and they have same names,
        /// they will logically appear as the same file in the project root. To disambiguate, we
        /// remove both files from the project's root and re-add them each into a folder chain that
        /// is formed from the full path of each document.
        /// </summary>
        private static Solution DisambiguateSameNameLinkedFiles(Project project)
        {
            var nameMap = project.Documents.Where(d => !d.Folders.Any()).ToLookup(d => d.Name);
            foreach (var conflictedItemGroup in nameMap.Where(g => g.Count() > 1))
            {
                foreach (var conflictedDocument in conflictedItemGroup)
                {
                    project = project.RemoveDocument(conflictedDocument.Id);
                    string filePath = conflictedDocument.FilePath;
                    DocumentId newId = DocumentId.CreateNewId(project.Id, filePath);
                    var folders = filePath.Split('\\').Select(p => p.TrimEnd(':'));
                    project = project.Solution.AddDocument(
                        newId,
                        conflictedDocument.Name,
                        conflictedDocument.GetTextAsync().Result,
                        folders,
                        filePath).GetProject(project.Id);
                }
            }

            return project.Solution;
        }
开发者ID:akrisiun,项目名称:SourceBrowser,代码行数:28,代码来源:SolutionGenerator.cs

示例3: AddPathToProject

        private static void AddPathToProject(ref Solution solution, ref Project project, string fileName, string contents)
        {
            var document = GetExistingDocument(project, fileName);
            if (document != null)
            {
                project = project.RemoveDocument(document.Id);
                solution = project.Solution;
            }

            Console.WriteLine($"\t - Adding {fileName} to project");
            document = project.AddDocument(fileName,
                contents,
                null,
                Path.Combine(Path.GetDirectoryName(project.FilePath), fileName));
            project = document.Project;
            solution = project.Solution;
        }
开发者ID:ffMathy,项目名称:pinvoke-1,代码行数:17,代码来源:Program.cs

示例4: ApplyChanges

        private void ApplyChanges()
        {
            foreach (var doc in Tasks)
            {
                _project = _generatorWorkspace.Solution?.Projects.FirstOrDefault(x => x.Name == doc.Item4);

                var oldDocument = _project?.Documents.FirstOrDefault(x => x.Name == doc.Item1);

                if (oldDocument != null)
                {
                    if (oldDocument.GetTextAsync().Result.ToString() != doc.Item2.ToString())
                    {
                        bool isEqual = oldDocument.Folders.SequenceEqual(doc.Item3);

                        if (isEqual)
                        {
                            _project = _project.RemoveDocument(oldDocument.Id);
                        }

                        var newDocument = _project?.AddDocument(doc.Item1, doc.Item2, doc.Item3);
                        _project = newDocument?.Project;
                        _generatorWorkspace.Solution = _project?.Solution;
                    }
                }
                else
                {
                    var newDocument = _project?.AddDocument(doc.Item1, doc.Item2, doc.Item3);
                    _project = newDocument?.Project;
                    _generatorWorkspace.Solution = _project?.Solution;
                }
            }
        }
开发者ID:yumapos,项目名称:Yumapos-WCF-Generator,代码行数:32,代码来源:SerilizationGeneration.cs

示例5: ApplyChanges

        private void ApplyChanges()
        {
            var dirCompletedEventArgs = new DirectoryInfo(_project.FilePath.Remove(_project.FilePath.LastIndexOf("\\", StringComparison.Ordinal)) + "\\ServiceReferences\\CompletedEventArgs");

            foreach (FileInfo file in dirCompletedEventArgs.GetFiles())
            {
                var redundantDocument = _project?.Documents.FirstOrDefault(x => x.Name == file.Name);

                if (redundantDocument != null && _competedArgsMethods.All(x => (x.Service + "_" + x.Name + "CompletedEventArgs") != file.Name.Remove(file.Name.IndexOf(".", StringComparison.Ordinal))))
                    _project = _project?.RemoveDocument(redundantDocument.Id);

            }

            foreach (var doc in tasks)
            {
                _project = _generatorWorkspace.Solution?.Projects.FirstOrDefault(x => x.Name == doc.Item4);

                var oldDocument = _project?.Documents.FirstOrDefault(x => x.Name == doc.Item1);

                if (oldDocument != null)
                {
                    if (oldDocument.GetTextAsync().Result.ToString() != doc.Item2.ToString())
                    {
                        bool isEqual = oldDocument.Folders.SequenceEqual(doc.Item3);

                        if (isEqual)
                        {
                            _project = _project.RemoveDocument(oldDocument.Id);
                        }

                        var newDocument = _project?.AddDocument(doc.Item1, doc.Item2, doc.Item3);
                        _project = newDocument?.Project;
                        _generatorWorkspace.Solution = _project?.Solution;
                    }
                }
                else
                {
                    var newDocument = _project?.AddDocument(doc.Item1, doc.Item2, doc.Item3);
                    _project = newDocument?.Project;
                    _generatorWorkspace.Solution = _project?.Solution;
                }
            }

            _generatorWorkspace.Solution = _project.Solution;
            _generatorWorkspace.ApplyChanges();
        }
开发者ID:yumapos,项目名称:Yumapos-WCF-Generator,代码行数:46,代码来源:WCFGenerator.cs


注:本文中的Microsoft.CodeAnalysis.Project.RemoveDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。