Example #1
0
 public new void Close()
 {
     if (tunnelCurrent == this)
     {
         tunnelCurrent = null;
     }
     tunnelActiveList.Remove(this);
     base.Close();
     if (tunnelActiveList.Count == 0)
     {
         RestoreTabExpansion();
     }
 }
Example #2
0
        protected override void ProcessRecord()
        {
            Runspace runspace = System.Management.Automation.Runspaces.Runspace.DefaultRunspace;

            for (int i = 0; i < HostAddress.Length; i++)
            {
                Binding binding = ((Binding != null) && (i < Binding.Length)) ? Binding[i] : CreateDefaultBinding();
                Tunnel  tunnel  = new Tunnel(runspace, binding, new EndpointAddress(HostAddress[i]));
                if (!NoSelect.IsPresent)
                {
                    tunnel.SetAsCurrent();
                }
                this.WriteObject(tunnel);
            }

            base.ProcessRecord();
        }
Example #3
0
        protected override void EndProcessing()
        {
            Tunnel tunnel = (Tunnel != null) ? Tunnel : Tunnel.TunnelCurrent;

            if (tunnel == null)
            {
                throw new ApplicationException("Invoke-Tunnel failed: no specified or current tunnel.");
            }

            byte[][] pipeAsByteArrayArray;

            if (entirePipeLine.Count == 0)
            {
                pipeAsByteArrayArray = null;
            }
            else
            {
                pipeAsByteArrayArray = new byte[entirePipeLine.Count][];
                for (int i = 0; i < entirePipeLine.Count; i++)
                {
                    pipeAsByteArrayArray[i] = Tunnel.SerializeToByteArray(entirePipeLine[i]);
                }
            }

            if (scriptBlock != null)
            {
                byte[][] byteArrayArray = tunnel.RunScript(scriptBlock.ToString(), pipeAsByteArrayArray, PipeOutput.IsPresent);

                foreach (byte[] byteArray in byteArrayArray)
                {
                    this.WriteObject(Tunnel.DeserializeToObject(byteArray));
                }
            }

            base.EndProcessing();
        }
Example #4
0
 public void SetAsCurrent()
 {
     tunnelCurrent = this;
 }