コード例 #1
0
ファイル: SftpMessage.cs プロジェクト: sshnet/SSH.NET
        private static SftpMessage Load(uint protocolVersion, SftpMessageTypes messageType, byte[] data, int offset, int count, Encoding encoding)
        {
            SftpMessage message;

            switch (messageType)
            {
                case SftpMessageTypes.Version:
                    message = new SftpVersionResponse();
                    break;
                case SftpMessageTypes.Status:
                    message = new SftpStatusResponse(protocolVersion);
                    break;
                case SftpMessageTypes.Data:
                    message = new SftpDataResponse(protocolVersion);
                    break;
                case SftpMessageTypes.Handle:
                    message = new SftpHandleResponse(protocolVersion);
                    break;
                case SftpMessageTypes.Name:
                    message = new SftpNameResponse(protocolVersion, encoding);
                    break;
                case SftpMessageTypes.Attrs:
                    message = new SftpAttrsResponse(protocolVersion);
                    break;
                case SftpMessageTypes.ExtendedReply:
                    message = new SftpExtendedReplyResponse(protocolVersion);
                    break;
                default:
                    throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Message type '{0}' is not supported.", messageType));
            }

            message.Load(data, offset, count);

            return message;
        }
コード例 #2
0
ファイル: SftpMessage.cs プロジェクト: vallamble/win-sshfs
 private static SftpMessage Load(byte[] data, SftpMessageTypes messageType)
 {
     if (SftpMessage._sftpMessageTypes.ContainsKey(messageType))
     {
         return(SftpMessage._sftpMessageTypes[messageType](data));
     }
     else
     {
         throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Message type '{0}' is not registered.", messageType));
     }
 }
コード例 #3
0
ファイル: SftpMessage.cs プロジェクト: lrdcasimir/ssh.net
        private static SftpMessage Load(uint protocolVersion, byte[] data, SftpMessageTypes messageType, Encoding encoding)
        {
            SftpMessage message;

            switch (messageType)
            {
            case SftpMessageTypes.Version:
                message = new SftpVersionResponse();
                break;

            case SftpMessageTypes.Status:
                message = new SftpStatusResponse(protocolVersion);
                break;

            case SftpMessageTypes.Data:
                message = new SftpDataResponse(protocolVersion);
                break;

            case SftpMessageTypes.Handle:
                message = new SftpHandleResponse(protocolVersion);
                break;

            case SftpMessageTypes.Name:
                message = new SftpNameResponse(protocolVersion, encoding);
                break;

            case SftpMessageTypes.Attrs:
                message = new SftpAttrsResponse(protocolVersion);
                break;

            case SftpMessageTypes.ExtendedReply:
                message = new SftpExtendedReplyResponse(protocolVersion);
                break;

            default:
                throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Message type '{0}' is not supported.", messageType));
            }

#if TUNING
            message.Load(data);
#else
            message.LoadBytes(data);

            message.ResetReader();

            message.LoadData();
#endif

            return(message);
        }
コード例 #4
0
ファイル: SftpMessage.cs プロジェクト: nemec/Blossom
        private static SftpMessage Load(byte[] data, SftpMessageTypes messageType)
        {
            SftpMessage message = null;

            switch (messageType)
            {
                case SftpMessageTypes.Version:
                    message = new SftpVersionResponse();
                    break;
                case SftpMessageTypes.Status:
                    message = new SftpStatusResponse();
                    break;
                case SftpMessageTypes.Data:
                    message = new SftpDataResponse();
                    break;
                case SftpMessageTypes.Handle:
                    message = new SftpHandleResponse();
                    break;
                case SftpMessageTypes.Name:
                    message = new SftpNameResponse();
                    break;
                case SftpMessageTypes.Attrs:
                    message = new SftpAttrsResponse();
                    break;
                case SftpMessageTypes.ExtendedReply:
                    message = new SftpExtendedReplyResponse();
                    break;
                default:
                    throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Message type '{0}' is not supported.", messageType));
            }

            message.LoadBytes(data);

            message.ResetReader();

            message.LoadData();

            return message;
        }