Esempio n. 1
0
		internal Executor(PowwaHost parent, bool useNestedPipelines, bool isPromptFunctionExecutor)
		{
			this.instanceStateLock = new object();
			this.parent = parent;
			this.useNestedPipelines = useNestedPipelines;
			this.isPromptFunctionExecutor = isPromptFunctionExecutor;
			this.Reset();
		}
Esempio n. 2
0
 public WebReader(PowwaHost host)
 {
     _host = host;
 }
Esempio n. 3
0
 public WebWriter(PowwaHost host)
 {
     _host = host;
 }
Esempio n. 4
0
        internal PowwaSession(string sessionId, string sessionUser, RunspaceConnectionInfo connectionInfo, ClientInfo clientInfo)
        {
            EventHandler <MessageCreatedEventArgs> eventHandler  = null;
            EventHandler <MessageCreatedEventArgs> eventHandler1 = null;
            EventHandler <MessageCreatedEventArgs> eventHandler2 = null;

            if (sessionId != null)
            {
                if (connectionInfo != null)
                {
                    if (clientInfo != null)
                    {
                        this.Id       = sessionId;
                        this.Name     = string.Empty;
                        this.UserName = sessionUser;
                        this.host     = new PowwaHost(clientInfo);
                        this.host.UI.RawUI.WindowTitle = connectionInfo.ComputerName;
                        PowwaHost powwaHost = this.host;
                        if (eventHandler == null)
                        {
                            eventHandler = (object sender, MessageCreatedEventArgs e) => this.OnClientMessageCreated(e);
                        }
                        powwaHost.MessageCreated += eventHandler;
                        IMessageCreated uI = (IMessageCreated)this.host.UI;
                        if (eventHandler1 == null)
                        {
                            eventHandler1 = (object sender, MessageCreatedEventArgs e) => this.OnClientMessageCreated(e);
                        }
                        uI.MessageCreated += eventHandler1;
                        IMessageCreated rawUI = (IMessageCreated)this.host.UI.RawUI;
                        if (eventHandler2 == null)
                        {
                            eventHandler2 = (object sender, MessageCreatedEventArgs e) => this.OnClientMessageCreated(e);
                        }
                        rawUI.MessageCreated                    += eventHandler2;
                        this.Runspace                            = RunspaceFactory.CreateRunspace(connectionInfo, this.host, PowwaSession.TypeTableLoader.Instance.LoadDefaultTypeFiles());
                        this.Runspace.StateChanged              += new EventHandler <RunspaceStateEventArgs>(this.OnRunspaceStateChanged);
                        this.executingCommandPowerShell          = System.Management.Automation.PowerShell.Create();
                        this.executingCommandPowerShell.Runspace = this.Runspace;
                        this.executingCommandPowerShell.InvocationStateChanged += new EventHandler <PSInvocationStateChangedEventArgs>(this.OnExecutingCommandInvocationStateChanged);
                        this.messageQueue      = new MessageQueue();
                        this.clientRequestLock = new object();
                        this.cancelCommandLock = new object();
                        this.sessionStateLock  = new object();
                        this.SessionKey        = PowwaSession.CreateSessionKey();
                        this.State             = PowwaSession.SessionState.Available;
                        try {
                            this.Runspace.Open();
                        }
                        catch (Exception ex)
                        {
                            var stackTrace = ex.StackTrace;
                            System.Diagnostics.Debug.WriteLine(stackTrace);
                        }
                        this.exec = new Microsoft.PowerShell.Executor(this.host, false, false);
                        this.exec.OutputHandler += HandleOutputHandler;
                        if (this.messageQueue.GetMessageCount() > 0)
                        {
                            this.PostClientMessage(new CommandCompletedMessage(this.GetPowerShellPrompt()), false);
                        }
                        return;
                    }
                    else
                    {
                        throw new ArgumentNullException("clientInfo");
                    }
                }
                else
                {
                    throw new ArgumentNullException("connectionInfo");
                }
            }
            else
            {
                throw new ArgumentNullException("sessionId");
            }
        }
Esempio n. 5
0
			public WebReader(PowwaHost host)
			{
				_host = host;
			}
Esempio n. 6
0
			public WebWriter(PowwaHost host)
			{
				_host = host;
			}