internal ScriptSession(string applianceType, bool personalizedSettings) { // Create and open a PowerShell runspace. A runspace is a container // that holds PowerShell pipelines, and provides access to the state // of the Runspace session (aka SessionState.) ApplianceType = applianceType; Settings = ApplicationSettings.GetInstance(ApplianceType, personalizedSettings); host = new ScriptingHost(Settings, SpeInitialSessionState); host.Runspace.StateChanged += OnRunspaceStateEvent; NewPowerShell(); host.Runspace.Open(); if (!initialized) { Initialize(); } Runspace.DefaultRunspace = host.Runspace; // complete opening if (Runspace.DefaultRunspace == null) { //! wait while loading while (!isRunspaceOpenedOrBroken) Thread.Sleep(100); //! set default runspace for handlers //! it has to be done in main thread Runspace.DefaultRunspace = host.Runspace; } Output.Clear(); }
internal ScriptSession(string applianceType, bool personalizedSettings) { // Create and open a PowerShell runspace. A runspace is a container // that holds PowerShell pipelines, and provides access to the state // of the Runspace session (aka SessionState.) ApplianceType = applianceType; Settings = ApplicationSettings.GetInstance(ApplianceType, personalizedSettings); var conf = RunspaceConfiguration.Create(); host = new ScriptingHost(Settings, conf); runspace = host.Runspace; conf.Cmdlets.Append(CognifideSitecorePowerShellSnapIn.Commandlets); if (Settings.UseTypeInfo) { conf.Formats.Prepend( new FormatConfigurationEntry(HttpRuntime.AppDomainAppPath + @"sitecore modules\PowerShell\Assets\Sitecore.Views.ps1xml")); conf.Formats.Update(); conf.Types.Prepend( new TypeConfigurationEntry(HttpRuntime.AppDomainAppPath + @"sitecore modules\PowerShell\Assets\Sitecore.Types.ps1xml")); conf.Types.Update(); } runspace.ThreadOptions = PSThreadOptions.UseCurrentThread; runspace.ApartmentState = ApartmentState.STA; PsSitecoreItemProvider.AppendToRunSpace(runspace.RunspaceConfiguration); runspace.Open(); if (!initialized) { Initialize(); } if (Settings.UseTypeInfo) { Output.Clear(); } }
internal ScriptingHostPrivateData(ScriptingHost host) { ScriptingHost = host; }
public ScriptingHostUserInterface(ApplicationSettings settings, ScriptingHost host) { rawUi = new ScriptingHostRawUserInterface(settings); this.host = host; }