public static Datagram ResolveRequest(byte[] rawDatagram)
        {
            Datagram result = null;

            Datagram temp = new DatagramRequest();

            temp.Parse(rawDatagram);

            if (DatagramResolver.HeadTag.SequenceEqual(temp.Head))
            {
                if (temp.CommandCode.SequenceEqual(HeartbeatRequest.FixCommandCode) &&
                    rawDatagram.Length == HeartbeatRequest.Length)
                {
                    result = new HeartbeatRequest();
                }

                if (temp.CommandCode.SequenceEqual(LoginRequest.FixCommandCode) &&
                    rawDatagram.Length == LoginRequest.Length)
                {
                    result = new LoginRequest();
                }

                if (temp.CommandCode.SequenceEqual(BlacklistQueryRequest.FixCommandCode) &&
                   rawDatagram.Length == BlacklistQueryRequest.Length)
                {
                    result = new BlacklistQueryRequest();
                }

                if (temp.CommandCode.SequenceEqual(BlacklistDownloadRequest.FixCommandCode) &&
                   rawDatagram.Length == BlacklistDownloadRequest.Length)
                {
                    result = new BlacklistDownloadRequest();
                }

                if (temp.CommandCode.SequenceEqual(CurrencyRequest.FixCommandCode) &&
                    rawDatagram.Length == CurrencyRequest.Length)
                {
                    result = new CurrencyRequest();
                }

                if (result != null)
                {
                    result.Parse(rawDatagram);
                }
            }

            return result;
        }
        public static Datagram ResolveRequest(byte[] rawDatagram)
        {
            Datagram result = null;

            Datagram temp = new DatagramRequest();

            temp.Parse(rawDatagram);

            if (DatagramResolver.HeadTag.SequenceEqual(temp.Head))
            {
                if (temp.CommandCode.SequenceEqual(HeartbeatRequest.FixCommandCode) &&
                    rawDatagram.Length == HeartbeatRequest.Length)
                {
                    result = new HeartbeatRequest();
                }

                if (temp.CommandCode.SequenceEqual(LoginRequest.FixCommandCode) &&
                    rawDatagram.Length == LoginRequest.Length)
                {
                    result = new LoginRequest();
                }

                if (temp.CommandCode.SequenceEqual(BlacklistQueryRequest.FixCommandCode) &&
                    rawDatagram.Length == BlacklistQueryRequest.Length)
                {
                    result = new BlacklistQueryRequest();
                }

                if (temp.CommandCode.SequenceEqual(BlacklistDownloadRequest.FixCommandCode) &&
                    rawDatagram.Length == BlacklistDownloadRequest.Length)
                {
                    result = new BlacklistDownloadRequest();
                }

                if (temp.CommandCode.SequenceEqual(CurrencyRequest.FixCommandCode) &&
                    rawDatagram.Length == CurrencyRequest.Length)
                {
                    result = new CurrencyRequest();
                }

                if (result != null)
                {
                    result.Parse(rawDatagram);
                }
            }

            return(result);
        }