private static Tuple<Runspace, DagentPSHost> CreateRunspace(IConsole console, string hostName) { var initialSessionState = InitialSessionState.CreateDefault(); var privateData = new Tuple<string, object>[] { }; var host = new DagentPSHost(hostName, privateData) { ActiveConsole = console }; var runspace = RunspaceFactory.CreateRunspace(host, initialSessionState); runspace.ThreadOptions = PSThreadOptions.Default; runspace.Open(); // // Set this runspace as DefaultRunspace so I can script DTE events. // WARNING: MSDN says this is unsafe. The runspace must not be shared across threads. I need this to be able to use ScriptBlock for DTE events. The ScriptBlock event handlers execute on DefaultRunspace. // Runspace.DefaultRunspace = runspace; return Tuple.Create(runspace, host); }
public DagentPSHostUserInterface(DagentPSHost host) { if (host == null) throw new ArgumentNullException("host"); _host = host; }