コード例 #1
0
            public static TFTPPacket Deserialize(Stream s)
            {
                TFTPPacket result = null;

                long   startPosition = s.Position;
                Opcode c             = (Opcode)ReadUInt16(s);

                s.Position = startPosition;

                switch (c)
                {
                case Opcode.Ack:
                    result = new TFTPPacket_Ack(s);
                    break;

                case Opcode.Data:
                    result = new TFTPPacket_Data(s);
                    break;

                case Opcode.Error:
                    result = new TFTPPacket_Error(s);
                    break;

                case Opcode.OptionsAck:
                    result = new TFTPPacket_OptionsAck(s);
                    break;

                case Opcode.ReadRequest:
                    result = new TFTPPacket_ReadRequest(s);
                    break;

                case Opcode.WriteRequest:
                    result = new TFTPPacket_WriteRequest(s);
                    break;

                default:
                    result = new TFTPPacket_Unknown(s);
                    break;
                }

                return(result);
            }
コード例 #2
0
            public static TFTPPacket Deserialize(Stream s)
            {
                TFTPPacket result = null;

                long startPosition = s.Position;
                Opcode c = (Opcode)ReadUInt16(s);
                s.Position = startPosition;

                switch (c)
                {
                    case Opcode.Ack:
                        result = new TFTPPacket_Ack(s);
                        break;

                    case Opcode.Data:
                        result = new TFTPPacket_Data(s);
                        break;

                    case Opcode.Error:
                        result = new TFTPPacket_Error(s);
                        break;

                    case Opcode.OptionsAck:
                        result = new TFTPPacket_OptionsAck(s);
                        break;

                    case Opcode.ReadRequest:
                        result = new TFTPPacket_ReadRequest(s);
                        break;

                    case Opcode.WriteRequest:
                        result = new TFTPPacket_WriteRequest(s);
                        break;

                    default:
                        result = new TFTPPacket_Unknown(s);
                        break;
                }

                return result;
            }