| | | 1 | | using System; |
| | | 2 | | using System.Globalization; |
| | | 3 | | using System.Text; |
| | | 4 | | |
| | | 5 | | using Renci.SshNet.Sftp.Responses; |
| | | 6 | | |
| | | 7 | | namespace Renci.SshNet.Sftp |
| | | 8 | | { |
| | | 9 | | internal sealed class SftpResponseFactory : ISftpResponseFactory |
| | | 10 | | { |
| | | 11 | | public SftpMessage Create(uint protocolVersion, byte messageType, Encoding encoding) |
| | 32102 | 12 | | { |
| | 32102 | 13 | | var sftpMessageType = (SftpMessageTypes) messageType; |
| | | 14 | | |
| | | 15 | | SftpMessage message; |
| | | 16 | | |
| | | 17 | | #pragma warning disable IDE0010 // Add missing cases |
| | 32102 | 18 | | switch (sftpMessageType) |
| | | 19 | | { |
| | | 20 | | case SftpMessageTypes.Version: |
| | 626 | 21 | | message = new SftpVersionResponse(); |
| | 626 | 22 | | break; |
| | | 23 | | case SftpMessageTypes.Status: |
| | 15101 | 24 | | message = new SftpStatusResponse(protocolVersion); |
| | 15101 | 25 | | break; |
| | | 26 | | case SftpMessageTypes.Data: |
| | 3952 | 27 | | message = new SftpDataResponse(protocolVersion); |
| | 3952 | 28 | | break; |
| | | 29 | | case SftpMessageTypes.Handle: |
| | 390 | 30 | | message = new SftpHandleResponse(protocolVersion); |
| | 390 | 31 | | break; |
| | | 32 | | case SftpMessageTypes.Name: |
| | 11618 | 33 | | message = new SftpNameResponse(protocolVersion, encoding); |
| | 11618 | 34 | | break; |
| | | 35 | | case SftpMessageTypes.Attrs: |
| | 409 | 36 | | message = new SftpAttrsResponse(protocolVersion); |
| | 409 | 37 | | break; |
| | | 38 | | case SftpMessageTypes.ExtendedReply: |
| | 6 | 39 | | message = new SftpExtendedReplyResponse(protocolVersion); |
| | 6 | 40 | | break; |
| | | 41 | | default: |
| | 0 | 42 | | throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Message type '{0}' is not |
| | | 43 | | } |
| | | 44 | | #pragma warning restore IDE0010 // Add missing cases |
| | | 45 | | |
| | 32102 | 46 | | return message; |
| | 32102 | 47 | | } |
| | | 48 | | } |
| | | 49 | | } |