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


C# RequestContext.SendResult方法代码示例

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


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

示例1: HandleShutdownRequest

        private Task HandleShutdownRequest(
            object shutdownParams,
            RequestContext<object> requestContext)
        {
            // Allow the implementor to shut down gracefully
            this.Shutdown();

            return requestContext.SendResult(new object());
        }
开发者ID:sunnyc7,项目名称:PowerShellEditorServices,代码行数:9,代码来源:LanguageServerBase.cs

示例2: HandleInitializeRequest

        private async Task HandleInitializeRequest(
            object shutdownParams,
            RequestContext<object> requestContext)
        {
            // Send the Initialized event first so that we get breakpoints
            await requestContext.SendEvent(
                InitializedEvent.Type,
                null);

            // Now send the Initialize response to continue setup
            await requestContext.SendResult(new object());
        }
开发者ID:modulexcite,项目名称:PowerShellEditorServices,代码行数:12,代码来源:DebugAdapterBase.cs

示例3: HandleEvaluateRequest

        protected Task HandleEvaluateRequest(
            DebugAdapterMessages.EvaluateRequestArguments evaluateParams,
            RequestContext<DebugAdapterMessages.EvaluateResponseBody> requestContext)
        {
            // We don't await the result of the execution here because we want
            // to be able to receive further messages while the current script
            // is executing.  This important in cases where the pipeline thread
            // gets blocked by something in the script like a prompt to the user.
            var executeTask =
                this.editorSession.PowerShellContext.ExecuteScriptString(
                    evaluateParams.Expression,
                    true,
                    true);

            // Return the execution result after the task completes so that the
            // caller knows when command execution completed.
            executeTask.ContinueWith(
                (task) =>
                {
                    // Return an empty result since the result value is irrelevant
                    // for this request in the LanguageServer
                    return
                        requestContext.SendResult(
                            new DebugAdapterMessages.EvaluateResponseBody
                            {
                                Result = "",
                                VariablesReference = 0
                            });
                });

            return Task.FromResult(true);
        }
开发者ID:sunnyc7,项目名称:PowerShellEditorServices,代码行数:32,代码来源:LanguageServer.cs

示例4: HandleEvaluateRequest

        protected async Task HandleEvaluateRequest(
            DebugAdapterMessages.EvaluateRequestArguments evaluateParams,
            RequestContext<DebugAdapterMessages.EvaluateResponseBody> requestContext)
        {
            // We don't await the result of the execution here because we want
            // to be able to receive further messages while the current script
            // is executing.  This important in cases where the pipeline thread
            // gets blocked by something in the script like a prompt to the user.
            var executeTask =
                this.editorSession.PowerShellContext.ExecuteScriptString(
                    evaluateParams.Expression,
                    true,
                    true).ConfigureAwait(false);

            // Return an empty result since the result value is irrelevant
            // for this request in the LanguageServer
            await requestContext.SendResult(
                new DebugAdapterMessages.EvaluateResponseBody
                {
                    Result = "",
                    VariablesReference = 0
                });
        }
开发者ID:modulexcite,项目名称:PowerShellEditorServices,代码行数:23,代码来源:LanguageServer.cs

示例5: HandleDocumentSymbolRequest

        protected async Task HandleDocumentSymbolRequest(
            TextDocumentIdentifier textDocumentIdentifier,
            RequestContext<SymbolInformation[]> requestContext)
        {
            ScriptFile scriptFile =
                editorSession.Workspace.GetFile(
                    textDocumentIdentifier.Uri);

            FindOccurrencesResult foundSymbols =
                editorSession.LanguageService.FindSymbolsInFile(
                    scriptFile);

            SymbolInformation[] symbols = null;

            string containerName = Path.GetFileNameWithoutExtension(scriptFile.FilePath);

            if (foundSymbols != null)
            {
                symbols =
                    foundSymbols
                        .FoundOccurrences
                        .Select(r =>
                            {
                                return new SymbolInformation
                                {
                                    ContainerName = containerName,
                                    Kind = GetSymbolKind(r.SymbolType),
                                    Location = new Location
                                    {
                                        Uri = new Uri(r.FilePath).AbsolutePath,
                                        Range = GetRangeFromScriptRegion(r.ScriptRegion)
                                    },
                                    Name = GetDecoratedSymbolName(r)
                                };
                            })
                        .ToArray();
            }
            else
            {
                symbols = new SymbolInformation[0];
            }

            await requestContext.SendResult(symbols);
        }
开发者ID:modulexcite,项目名称:PowerShellEditorServices,代码行数:44,代码来源:LanguageServer.cs

示例6: HandleDocumentHighlightRequest

        protected async Task HandleDocumentHighlightRequest(
            TextDocumentPosition textDocumentPosition,
            RequestContext<DocumentHighlight[]> requestContext)
        {
            ScriptFile scriptFile =
                editorSession.Workspace.GetFile(
                    textDocumentPosition.Uri);

            FindOccurrencesResult occurrencesResult =
                editorSession.LanguageService.FindOccurrencesInFile(
                    scriptFile,
                    textDocumentPosition.Position.Line + 1,
                    textDocumentPosition.Position.Character + 1);

            DocumentHighlight[] documentHighlights = null;

            if (occurrencesResult != null)
            {
                documentHighlights =
                    occurrencesResult
                        .FoundOccurrences
                        .Select(o =>
                            {
                                return new DocumentHighlight
                                {
                                    Kind = DocumentHighlightKind.Write, // TODO: Which symbol types are writable?
                                    Range = GetRangeFromScriptRegion(o.ScriptRegion)
                                };
                            })
                        .ToArray();
            }
            else
            {
                documentHighlights = new DocumentHighlight[0];
            }

            await requestContext.SendResult(documentHighlights);
        }
开发者ID:modulexcite,项目名称:PowerShellEditorServices,代码行数:38,代码来源:LanguageServer.cs

示例7: HandleCompletionResolveRequest

        protected async Task HandleCompletionResolveRequest(
            CompletionItem completionItem,
            RequestContext<CompletionItem> requestContext)
        {
            if (completionItem.Kind == CompletionItemKind.Function)
            {
                RunspaceHandle runspaceHandle =
                    await editorSession.PowerShellContext.GetRunspaceHandle();

                // Get the documentation for the function
                CommandInfo commandInfo =
                    CommandHelpers.GetCommandInfo(
                        completionItem.Label,
                        runspaceHandle.Runspace);

                completionItem.Documentation =
                    CommandHelpers.GetCommandSynopsis(
                        commandInfo,
                        runspaceHandle.Runspace);

                runspaceHandle.Dispose();
            }

            // Send back the updated CompletionItem
            await requestContext.SendResult(completionItem);
        }
开发者ID:modulexcite,项目名称:PowerShellEditorServices,代码行数:26,代码来源:LanguageServer.cs

示例8: HandleReferencesRequest

        protected async Task HandleReferencesRequest(
            ReferencesParams referencesParams,
            RequestContext<Location[]> requestContext)
        {
            ScriptFile scriptFile =
                editorSession.Workspace.GetFile(
                    referencesParams.Uri);

            SymbolReference foundSymbol =
                editorSession.LanguageService.FindSymbolAtLocation(
                    scriptFile,
                    referencesParams.Position.Line + 1,
                    referencesParams.Position.Character + 1);

            FindReferencesResult referencesResult =
                await editorSession.LanguageService.FindReferencesOfSymbol(
                    foundSymbol,
                    editorSession.Workspace.ExpandScriptReferences(scriptFile));

            Location[] referenceLocations = null;

            if (referencesResult != null)
            {
                referenceLocations =
                    referencesResult
                        .FoundReferences
                        .Select(r =>
                            {
                                return new Location
                                {
                                    Uri = new Uri(r.FilePath).AbsoluteUri,
                                    Range = GetRangeFromScriptRegion(r.ScriptRegion)
                                };
                            })
                        .ToArray();
            }
            else
            {
                referenceLocations = new Location[0];
            }

            await requestContext.SendResult(referenceLocations);
        }
开发者ID:modulexcite,项目名称:PowerShellEditorServices,代码行数:43,代码来源:LanguageServer.cs

示例9: HandleExpandAliasRequest

        private async Task HandleExpandAliasRequest(
            string content,
            RequestContext<string> requestContext)
        {
            var script = @"
function __Expand-Alias {

    param($targetScript)

    [ref]$errors=$null
    
    $tokens = [System.Management.Automation.PsParser]::Tokenize($targetScript, $errors).Where({$_.type -eq 'command'}) | 
                    Sort Start -Descending

    foreach ($token in  $tokens) {
        $definition=(Get-Command ('`'+$token.Content) -CommandType Alias -ErrorAction SilentlyContinue).Definition

        if($definition) {        
            $lhs=$targetScript.Substring(0, $token.Start)
            $rhs=$targetScript.Substring($token.Start + $token.Length)
            
            $targetScript=$lhs + $definition + $rhs
       }
    }

    $targetScript
}";
            var psCommand = new PSCommand();
            psCommand.AddScript(script);
            await this.editorSession.PowerShellContext.ExecuteCommand<PSObject>(psCommand);

            psCommand = new PSCommand();
            psCommand.AddCommand("__Expand-Alias").AddArgument(content);
            var result = await this.editorSession.PowerShellContext.ExecuteCommand<string>(psCommand);

            await requestContext.SendResult(result.First().ToString());
        }
开发者ID:modulexcite,项目名称:PowerShellEditorServices,代码行数:37,代码来源:LanguageServer.cs

示例10: HandleSetExceptionBreakpointsRequest

        protected async Task HandleSetExceptionBreakpointsRequest(
            SetExceptionBreakpointsRequestArguments setExceptionBreakpointsParams,
            RequestContext<object> requestContext)
        {
            // TODO: Handle this appropriately

            await requestContext.SendResult(null);
        }
开发者ID:Bjakes1950,项目名称:PowerShellEditorServices,代码行数:8,代码来源:DebugAdapter.cs

示例11: HandleSetBreakpointsRequest

        protected async Task HandleSetBreakpointsRequest(
            SetBreakpointsRequestArguments setBreakpointsParams,
            RequestContext<SetBreakpointsResponseBody> requestContext)
        {
            ScriptFile scriptFile =
                editorSession.Workspace.GetFile(
                    setBreakpointsParams.Source.Path);

            BreakpointDetails[] breakpoints =
                await editorSession.DebugService.SetBreakpoints(
                    scriptFile,
                    setBreakpointsParams.Lines);

            await requestContext.SendResult(
                new SetBreakpointsResponseBody
                {
                    Breakpoints =
                        breakpoints
                            .Select(Protocol.DebugAdapter.Breakpoint.Create)
                            .ToArray()
                });
        }
开发者ID:Bjakes1950,项目名称:PowerShellEditorServices,代码行数:22,代码来源:DebugAdapter.cs

示例12: HandleDisconnectRequest

        protected Task HandleDisconnectRequest(
            object disconnectParams,
            RequestContext<object> requestContext)
        {
            EventHandler<SessionStateChangedEventArgs> handler = null;

            handler =
                async (o, e) =>
                {
                    if (e.NewSessionState == PowerShellContextState.Ready)
                    {
                        await requestContext.SendResult(null);
                        editorSession.PowerShellContext.SessionStateChanged -= handler;

                        // Stop the server
                        this.Stop();
                    }
                };

            editorSession.PowerShellContext.SessionStateChanged += handler;
            editorSession.PowerShellContext.AbortExecution();

            return Task.FromResult(true);
        }
开发者ID:Bjakes1950,项目名称:PowerShellEditorServices,代码行数:24,代码来源:DebugAdapter.cs

示例13: HandleLaunchRequest

        protected async Task HandleLaunchRequest(
            LaunchRequestArguments launchParams,
            RequestContext<object> requestContext)
        {
            // Set the working directory for the PowerShell runspace to the cwd passed in via launch.json. 
            // In case that is null, use the the folder of the script to be executed.  If the resulting 
            // working dir path is a file path then extract the directory and use that.
            string workingDir = launchParams.Cwd ?? launchParams.Program;
            try
            {
                if ((File.GetAttributes(workingDir) & FileAttributes.Directory) != FileAttributes.Directory)
                {
                    workingDir = Path.GetDirectoryName(workingDir);
                }
            }
            catch (Exception ex)
            {
                Logger.Write(LogLevel.Error, "cwd path is bad: " + ex.Message);
                workingDir = Environment.CurrentDirectory;
            }

            var setWorkingDirCommand = new PSCommand();
            setWorkingDirCommand.AddCommand(@"Microsoft.PowerShell.Management\Set-Location")
                .AddParameter("LiteralPath", workingDir);

            await editorSession.PowerShellContext.ExecuteCommand(setWorkingDirCommand);

            Logger.Write(LogLevel.Verbose, "Working dir set to: " + workingDir);

            // Prepare arguments to the script - if specified
            string arguments = null;
            if ((launchParams.Args != null) && (launchParams.Args.Length > 0))
            {
                arguments = string.Join(" ", launchParams.Args);
                Logger.Write(LogLevel.Verbose, "Script arguments are: " + arguments);
            }

            // Execute the given PowerShell script and send the response.
            // Note that we aren't waiting for execution to complete here
            // because the debugger could stop while the script executes.
            Task executeTask =
                editorSession.PowerShellContext
                    .ExecuteScriptAtPath(launchParams.Program, arguments)
                    .ContinueWith(
                        async (t) => {
                            Logger.Write(LogLevel.Verbose, "Execution completed, terminating...");

                            await requestContext.SendEvent(
                                TerminatedEvent.Type,
                                null);

                            // Stop the server
                            this.Stop();
                        });

            await requestContext.SendResult(null);
        }
开发者ID:sunnyc7,项目名称:PowerShellEditorServices,代码行数:57,代码来源:DebugAdapter.cs

示例14: HandleEvaluateRequest

        protected async Task HandleEvaluateRequest(
            DebugAdapterMessages.EvaluateRequestArguments evaluateParams,
            RequestContext<DebugAdapterMessages.EvaluateResponseBody> requestContext)
        {
            var results = 
                await this.editorSession.PowerShellContext.ExecuteScriptString(
                    evaluateParams.Expression,
                    true,
                    true);

            // Return an empty result since the result value is irrelevant
            // for this request in the LanguageServer
            await requestContext.SendResult(
                new DebugAdapterMessages.EvaluateResponseBody
                {
                    Result = "",
                    VariablesReference = 0
                });
        }
开发者ID:Bjakes1950,项目名称:PowerShellEditorServices,代码行数:19,代码来源:LanguageServer.cs

示例15: HandleLaunchRequest

        protected async Task HandleLaunchRequest(
            LaunchRequestArguments launchParams,
            RequestContext<object> requestContext)
        {
            // Execute the given PowerShell script and send the response.
            // Note that we aren't waiting for execution to complete here
            // because the debugger could stop while the script executes.
            Task executeTask =
                editorSession.PowerShellContext
                    .ExecuteScriptAtPath(launchParams.Program)
                    .ContinueWith(
                        async (t) =>
                        {
                            Logger.Write(LogLevel.Verbose, "Execution completed, terminating...");

                            await requestContext.SendEvent(
                                TerminatedEvent.Type,
                                null);

                            // Stop the server
                            this.Stop();
                        });

            await requestContext.SendResult(null);
        }
开发者ID:Bjakes1950,项目名称:PowerShellEditorServices,代码行数:25,代码来源:DebugAdapter.cs


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