Przeglądaj źródła

Add new default when creating shell and another shortcut

olegkap_cp 14 lat temu
rodzic
commit
223b1fd909
1 zmienionych plików z 27 dodań i 1 usunięć
  1. 27 1
      Renci.SshClient/Renci.SshClient/SshClient.cs

+ 27 - 1
Renci.SshClient/Renci.SshClient/SshClient.cs

@@ -202,12 +202,38 @@ namespace Renci.SshClient
         /// <param name="height">The height.</param>
         /// <param name="terminalMode">The terminal mode.</param>
         /// <returns></returns>
-        public Shell CreateShell(Stream input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, string terminalMode, int bufferSize = 1024)
+        public Shell CreateShell(Stream input, Stream output, Stream extendedOutput, string terminalName = "", uint columns = 0, uint rows = 0, uint width = 0, uint height = 0, string terminalMode = "", int bufferSize = 1024)
         {
             //  Ensure that connection is established.
             this.EnsureConnection();
 
             return new Shell(this.Session, input, output, extendedOutput, terminalName, columns, rows, width, height, terminalMode, bufferSize);
         }
+
+        /// <summary>
+        /// Creates the shell. (not complete)
+        /// </summary>
+        /// <param name="input">The input.</param>
+        /// <param name="output">The output.</param>
+        /// <param name="extendedOutput">The extended output.</param>
+        /// <param name="terminalName">Name of the terminal.</param>
+        /// <param name="columns">The columns.</param>
+        /// <param name="rows">The rows.</param>
+        /// <param name="width">The width.</param>
+        /// <param name="height">The height.</param>
+        /// <param name="terminalMode">The terminal mode.</param>
+        /// <returns></returns>
+        public Shell CreateShell(Encoding encoding, string input, Stream output, Stream extendedOutput, string terminalName = "", uint columns = 0, uint rows = 0, uint width = 0, uint height = 0, string terminalMode = "", int bufferSize = 1024)
+        {
+            //  Ensure that connection is established.
+            this.EnsureConnection();
+
+            var inputStream = new MemoryStream();
+            new StreamWriter(inputStream, encoding).Write(input);
+            inputStream.Seek(0, SeekOrigin.Begin);
+
+            return new Shell(this.Session, inputStream, output, extendedOutput, terminalName, columns, rows, width, height, terminalMode, bufferSize);
+        }
+
     }
 }