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


C# ISolution.UpdateDocument方法代码示例

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


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

示例1: updateMethodInvocations

                    /* Update all the method invocations in the solution. */
                    private ISolution updateMethodInvocations(ISolution solution)
                    {
                        // Get all the documents in the solution.
                        var solutionAnalyzer = AnalyzerFactory.GetSolutionAnalyzer();
                        solutionAnalyzer.SetSolution(solution);
                        var documents = solutionAnalyzer.GetAllDocuments();

                        // Get the retriever for method invocations.
                        var retriever = RetrieverFactory.GetMethodInvocationRetriever();
                        retriever.SetMethodDeclaration(declaration);

                        // For each document
                        foreach (var document in documents)
                        {
                            // Get all the invocations in the document for the given method
                            // declaration.
                            retriever.SetDocument(document);
                            var invocations = retriever.GetInvocations();

                            // If there are invocations in the document.
                            if (invocations.Any())
                            {
                                // Update root
                                var root = (SyntaxNode) document.GetSyntaxRoot();
                                var updatedRoot = new InvocationsAddArgumentsRewriter(invocations, typeNameTuples.Select(t => t.Item2)).
                                    Visit(root);

                                // Update solution by update the document.
                                solution = solution.UpdateDocument(document.Id, updatedRoot);
                            }
                        }
                        return solution;
                    }
开发者ID:nkcsgexi,项目名称:ghostfactor1,代码行数:34,代码来源:ParametersChecker.cs

示例2: updateMethodDeclaration

                    private ISolution updateMethodDeclaration(ISolution solution)
                    {
                        // Get the qualified name of the RefactoringType containing the declaration.
                        var qualifidedNameAnalyzer = AnalyzerFactory.GetQualifiedNameAnalyzer();
                        qualifidedNameAnalyzer.SetSyntaxNode(declaration);
                        var typeName = qualifidedNameAnalyzer.GetOutsideTypeQualifiedName();

                        // Get all documents in the given originalSolution.
                        var solutionAnalyzer = AnalyzerFactory.GetSolutionAnalyzer();
                        solutionAnalyzer.SetSolution(solution);
                        var documents = solutionAnalyzer.GetAllDocuments();

                        // Get the simplified name of the method
                        var methodName = ((MethodDeclarationSyntax) declaration).Identifier.ValueText;

                        // For each document in the originalSolution.
                        foreach (var document in documents)
                        {
                            var documentAnalyzer = AnalyzerFactory.GetDocumentAnalyzer();
                            documentAnalyzer.SetDocument(document);

                            // If the document contains the RefactoringType in which the method is declared.
                            if (documentAnalyzer.ContainsQualifiedName(typeName))
                            {
                                // Get the root of the current document.
                                var root = ((SyntaxNode) document.GetSyntaxRoot());

                                // Find the method
                                SyntaxNode method = root.DescendantNodes().Where(
                                    // Find all the method declarations.
                                    n => n.Kind == SyntaxKind.MethodDeclaration).
                                    // Convert all of them to the RefactoringType MethodDeclarationSyntax.
                                    Select(n => (MethodDeclarationSyntax) n).
                                    // Get the one whose name is same with the given method declaration.
                                    First(m => m.Identifier.ValueText.Equals(methodName));

                                // If we can find this method.
                                if (method != null)
                                {
                                    // Get the updated method declaration.
                                    var methodAnalyzer = AnalyzerFactory.GetMethodDeclarationAnalyzer();
                                    methodAnalyzer.SetMethodDeclaration(method);
                                    var updatedMethod = methodAnalyzer.AddParameters(typeNameTuples);

                                    // Update the root, document and finally return the code action.
                                    var updatedRoot = new MethodDeclarationRewriter(method, updatedMethod).Visit(root);
                                    return solution.UpdateDocument(document.Id, updatedRoot);
                                }
                            }
                        }
                        return solution;
                    }
开发者ID:nkcsgexi,项目名称:ghostfactor1,代码行数:52,代码来源:ParametersChecker.cs


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