public ProtocolChoicePromptHandler( ILanguageServer languageServer, IHostInput hostInput, IHostOutput hostOutput, ILogger logger) : base(hostOutput, logger) { _languageServer = languageServer; this._hostInput = hostInput; this.hostOutput = hostOutput; }
public Host(IServiceProvider services, IServiceCollection pool, IAppBuilder appBuilder, IEnvironment hostEnv, IOutputEngine output, IHostInput hostInput, IHistoryProvider historyProvider) { this.services = services; this.pool = pool; this.appBuilder = appBuilder; this.hostEnv = hostEnv; this.output = output; this.hostInput = hostInput as HostInput; this.historyProvider = historyProvider; }
public ProtocolChoicePromptHandler( IMessageSender messageSender, IHostInput hostInput, IHostOutput hostOutput, ILogger logger) : base(hostOutput, logger) { this.hostInput = hostInput; this.hostOutput = hostOutput; this.messageSender = messageSender; }
/// <summary> /// Starts a debug-only session using the provided IConsoleHost implementation /// for the ConsoleService. /// </summary> /// <param name="powerShellContext"></param> /// <param name="hostInput"></param> /// <param name="editorOperations"> /// An IEditorOperations implementation used to interact with the editor. /// </param> public void StartDebugSession( PowerShellContext powerShellContext, IHostInput hostInput, IEditorOperations editorOperations) { this.PowerShellContext = powerShellContext; this.HostInput = hostInput; // Initialize all services this.RemoteFileManager = new RemoteFileManager(this.PowerShellContext, editorOperations, logger); this.DebugService = new DebugService(this.PowerShellContext, this.RemoteFileManager, logger); // Create a workspace to contain open files this.Workspace = new Workspace(this.PowerShellContext.LocalPowerShellVersion.Version, this.logger); }
/// <summary> /// Starts the session using the provided IConsoleHost implementation /// for the ConsoleService. /// </summary> /// <param name="powerShellContext"></param> /// <param name="hostInput"></param> public void StartSession( PowerShellContext powerShellContext, IHostInput hostInput) { this.PowerShellContext = powerShellContext; this.HostInput = hostInput; // Initialize all services this.LanguageService = new LanguageService(this.PowerShellContext, this.logger); this.ExtensionService = new ExtensionService(this.PowerShellContext); this.TemplateService = new TemplateService(this.PowerShellContext, this.logger); this.InstantiateAnalysisService(); // Create a workspace to contain open files this.Workspace = new Workspace(this.PowerShellContext.LocalPowerShellVersion.Version, this.logger); }
protected virtual void Dispose(bool disposing) { lock (_disposeSyncObject) { if (_isDisposed || !disposing) { return; } while (NestedPromptLevel > 1) { _consoleReader?.StopCommandLoop(); var currentFrame = CurrentFrame; if (currentFrame.FrameType.HasFlag(PromptNestFrameType.Debug)) { _versionSpecificOperations.StopCommandInDebugger(_powerShellContext); currentFrame.ThreadController.StartThreadExit(DebuggerResumeAction.Stop); currentFrame.WaitForFrameExit(CancellationToken.None); continue; } if (currentFrame.FrameType.HasFlag(PromptNestFrameType.NestedPrompt)) { _powerShellContext.ExitAllNestedPrompts(); continue; } currentFrame.PowerShell.BeginStop(null, null); currentFrame.WaitForFrameExit(CancellationToken.None); } _consoleReader?.StopCommandLoop(); _readLineFrame.Dispose(); CurrentFrame.Dispose(); _frameStack.Clear(); _powerShellContext = null; _consoleReader = null; _isDisposed = true; } }
/// <summary> /// Initializes a new instance of the <see cref="PromptNest" /> class. /// </summary> /// <param name="powerShellContext"> /// The <see cref="PowerShellContext" /> to track prompt status for. /// </param> /// <param name="initialPowerShell"> /// The <see cref="PowerShell" /> instance for the first frame. /// </param> /// <param name="consoleReader"> /// The input handler. /// </param> /// <param name="versionSpecificOperations"> /// The <see cref="IVersionSpecificOperations" /> for the calling /// <see cref="PowerShellContext" /> instance. /// </param> /// <remarks> /// This constructor should only be called when <see cref="PowerShellContext.CurrentRunspace" /> /// is set to the initial runspace. /// </remarks> internal PromptNest( PowerShellContextService powerShellContext, PowerShell initialPowerShell, IHostInput consoleReader, IVersionSpecificOperations versionSpecificOperations) { _versionSpecificOperations = versionSpecificOperations; _consoleReader = consoleReader; _powerShellContext = powerShellContext; _frameStack = new ConcurrentStack <PromptNestFrame>(); _frameStack.Push( new PromptNestFrame( initialPowerShell, NewHandleQueue())); var readLineShell = PowerShell.Create(); readLineShell.Runspace = powerShellContext.CurrentRunspace.Runspace; _readLineFrame = new PromptNestFrame( readLineShell, new AsyncQueue <RunspaceHandle>()); ReleaseRunspaceHandleImpl(isReadLine: true); }
public Task Invoke(IHostContext context, Func <Task> next, IServiceProvider services, ICommandProvider commandProvider, IEnvironment env, IOutputEngine outputEngine, IHostInput hostInput) { IInput input = context.Command; if (input.Name == "help") { return(ProcessWithHelp(input, context, commandProvider)); } CommandRecord command = commandProvider.MatchCommand(context); if (command == null) { return(next()); } MethodInfo methodInfo = command.CommandEntry; ParameterInfo[] parameters = methodInfo.GetParameters(); List <int> pathIndices = new List <int>(); foreach (var parameter in parameters) { if (parameter.GetCustomAttribute <PathAttribute>() != null) { pathIndices.Add(parameter.Position); } } try { CommandSet instance = (CommandSet)ObjectFactory.CreateInstance(command.InstanceType, services, input.Options, input.Arguments); instance.Command = input; instance.Context = context; instance.InputObject = context.InputObject; instance.OutputEngine = outputEngine; instance.HostInput = hostInput; instance.Environment = env; object value; if (pathIndices.Count <= 0) { value = ObjectFactory.InvokeMethod(instance, methodInfo, services, input.Options, input.Arguments); } else { MethodInvokeContext invokeContext = ObjectFactory.CreateInvokeContext(methodInfo, services, input.Options, input.Arguments); string currentPath = env.WorkingDirectory.FullName; ProcessPathAttribute(pathIndices, parameters, invokeContext.Arguments, currentPath); value = invokeContext.Invoke(instance); } if (command.CommandEntry.ReturnType != typeof(void)) { context.SetResult(value); } } catch (Exception ex) { context.Exception = ex; } return(Task.CompletedTask); }