public static Command Receive(Connection connection, byte[] receivedBuffer)
        {
            if (connection == null)
                throw new ArgumentNullException("connection");
            if (receivedBuffer == null)
                throw new ArgumentNullException("buffer");
            if (receivedBuffer.Length < 10)
                throw new ArgumentException();

            CommandBuilder command = new CommandBuilder(connection, receivedBuffer);
            byte code = command.ReadByte();
            command.SetCommandCode(code);
            switch (code)
            {
                case 0x10:
                    return new Command10(command);
                case 0x11:
                    return new Command11(command);
                case 0x12:
                    return new Command12(command);
                case 0x13:
                    return new Command13(command);
                case 0x20:
                    return new Command20(command);
                case 0x21:
                    return new Command21(command);
                case 0x22:
                    return new Command22(command);
                case 0x23:
                    return new Command23(command);
                case 0x40:
                    return new Command40(command);
                case 0x41:
                    return new Command41(command);
                case 0x42:
                    return new Command42(command);
                case 0x43:
                    return new Command43(command);
                case 0x44:
                    return new Command44(command);
                case 0x45:
                    return new Command45(command);
                case 0x46:
                    return new Command46(command);
                case 0x50:
                    return new Command50(command);
                case 0x51:
                    return new Command51(command);
                case 0x52:
                    return new Command52(command);
                case 0x53:
                    return new Command53(command);
                case 0x54:
                    return new Command54(command);
                case 0x60:
                    return new Command60(command);
                case 0x61:
                    return new Command61(command);
                case 0x62:
                    return new Command62(command);
                case 0x63:
                    return new Command63(command);
                case 0x64:
                    return new Command64(command);
                case 0x70:
                    return new Command70(command);
                case 0x71:
                    return new Command71(command);
                case 0x72:
                    return new Command72(command);
                case 0x74:
                    return new Command74(command);
                case 0x75:
                    return new Command75(command);
                case 0x76:
                    return new Command76(command);
                case 0x78:
                    return new Command78(command);
                case 0x79:
                    return new Command79(command);
                case 0x7A:
                    return new Command7A(command);
                default:
                    throw new InvalidDataException();
            }
        }
示例#2
0
        public static Command Receive(Connection connection, byte[] receivedBuffer)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (receivedBuffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (receivedBuffer.Length < 10)
            {
                throw new ArgumentException();
            }

            CommandBuilder command = new CommandBuilder(connection, receivedBuffer);
            byte           code    = command.ReadByte();

            command.SetCommandCode(code);
            switch (code)
            {
            case 0x10:
                return(new Command10(command));

            case 0x11:
                return(new Command11(command));

            case 0x12:
                return(new Command12(command));

            case 0x13:
                return(new Command13(command));

            case 0x20:
                return(new Command20(command));

            case 0x21:
                return(new Command21(command));

            case 0x22:
                return(new Command22(command));

            case 0x23:
                return(new Command23(command));

            case 0x40:
                return(new Command40(command));

            case 0x41:
                return(new Command41(command));

            case 0x42:
                return(new Command42(command));

            case 0x43:
                return(new Command43(command));

            case 0x44:
                return(new Command44(command));

            case 0x45:
                return(new Command45(command));

            case 0x46:
                return(new Command46(command));

            case 0x50:
                return(new Command50(command));

            case 0x51:
                return(new Command51(command));

            case 0x52:
                return(new Command52(command));

            case 0x53:
                return(new Command53(command));

            case 0x54:
                return(new Command54(command));

            case 0x60:
                return(new Command60(command));

            case 0x61:
                return(new Command61(command));

            case 0x62:
                return(new Command62(command));

            case 0x63:
                return(new Command63(command));

            case 0x64:
                return(new Command64(command));

            case 0x70:
                return(new Command70(command));

            case 0x71:
                return(new Command71(command));

            case 0x72:
                return(new Command72(command));

            case 0x74:
                return(new Command74(command));

            case 0x75:
                return(new Command75(command));

            case 0x76:
                return(new Command76(command));

            case 0x78:
                return(new Command78(command));

            case 0x79:
                return(new Command79(command));

            case 0x7A:
                return(new Command7A(command));

            default:
                throw new InvalidDataException();
            }
        }