<PackageReference Include="SSH.NET" Version="2024.0.0" />

SftpResponseFactory

using Renci.SshNet.Sftp.Responses; using System; using System.Globalization; using System.Text; namespace Renci.SshNet.Sftp { internal sealed class SftpResponseFactory : ISftpResponseFactory { public SftpMessage Create(uint protocolVersion, byte messageType, Encoding encoding) { SftpMessageTypes sftpMessageTypes = (SftpMessageTypes)messageType; switch (sftpMessageTypes) { case SftpMessageTypes.Version: return new SftpVersionResponse(); case SftpMessageTypes.Status: return new SftpStatusResponse(protocolVersion); case SftpMessageTypes.Data: return new SftpDataResponse(protocolVersion); case SftpMessageTypes.Handle: return new SftpHandleResponse(protocolVersion); case SftpMessageTypes.Name: return new SftpNameResponse(protocolVersion, encoding); case SftpMessageTypes.Attrs: return new SftpAttrsResponse(protocolVersion); case SftpMessageTypes.ExtendedReply: return new SftpExtendedReplyResponse(protocolVersion); default: throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Message type '{0}' is not supported.", sftpMessageTypes)); } } } }