コード例 #1
0
        private static async Task <Solution> Replace(string findExpression, string replaceExpression, CancellationToken cancellationToken)
        {
            var scriptResult = await ScriptRunner.RunScriptAsync(findExpression, new ScriptGlobals(cancellationToken), cancellationToken);

            var nodesAndTokens  = RoslynHelpers.GetSyntaxNodesAndTokens(MakeEnumerable(scriptResult));
            var currentSolution = RoslynVisxHelpers.GetWorkspace().CurrentSolution;

            return(await currentSolution.ReplaceNodesWithLiteralAsync(nodesAndTokens, replaceExpression, cancellationToken));
        }
コード例 #2
0
        private ListViewItem CreateListViewItem(object item)
        {
            var syntaxNodeorToken = RoslynHelpers.AsSyntaxNodeOrToken(item);

            if (syntaxNodeorToken != null)
            {
                return(new SyntaxNodeOrTokenListItem(syntaxNodeorToken.Value));
            }

            return(new ListViewItem()
            {
                Content = item?.ToString() ?? "<null>"
            });
        }