public static BinaryRequest Read(BinaryReader requestReader)
        {
            byte version = BinaryHelper.ReadByte(requestReader);

            if (version != BinaryRequest.Version)
            {
                throw new CorrespondenceException(String.Format("This distributor cannot read version {0} requests.", version));
            }

            string domain = BinaryHelper.ReadString(requestReader);

            byte token = BinaryHelper.ReadByte(requestReader);

            if (token == GetManyRequest.Token)
            {
                return(GetManyRequest.CreateAndRead(domain, requestReader));
            }
            else if (token == PostResponse.Token)
            {
                return(PostRequest.CreateAndRead(domain, requestReader));
            }
            else if (token == WindowsPhoneSubscribeRequest.Token)
            {
                return(WindowsPhoneSubscribeRequest.CreateAndRead(domain, requestReader));
            }
            else if (token == WindowsPhoneUnsubscribeRequest.Token)
            {
                return(WindowsPhoneUnsubscribeRequest.CreateAndRead(domain, requestReader));
            }
            else if (token == InterruptRequest.Token)
            {
                return(InterruptRequest.CreateAndRead(domain, requestReader));
            }
            else if (token == NotifyRequest.Token)
            {
                return(NotifyRequest.CreateAndRead(domain, requestReader));
            }
            else
            {
                throw new CorrespondenceException(String.Format("Unknown token {0}.", token));
            }
        }
 public static PostRequest CreateAndRead(string domain, BinaryReader requestReader)
 {
     var request = new PostRequest();
     request.ReadInternal(domain, requestReader);
     return request;
 }