The MD5OfMessageBody and MessageId elements.
상속: Amazon.Runtime.AmazonWebServiceResponse
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            SendMessageResponse response = new SendMessageResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;
            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {                    
                    if(context.TestExpression("SendMessageResult", 2))
                    {
                        UnmarshallResult(context, response);                        
                        continue;
                    }
                    
                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return response;
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, SendMessageResponse response)
        {
            
            int originalDepth = context.CurrentDepth;
            int targetDepth = originalDepth + 1;
            
            if (context.IsStartOfDocument) 
               targetDepth += 2;
            
            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {

                    if (context.TestExpression("MD5OfMessageAttributes", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.MD5OfMessageAttributes = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("MD5OfMessageBody", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.MD5OfMessageBody = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("MessageId", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.MessageId = unmarshaller.Unmarshall(context);
                        continue;
                    }
                    if (context.TestExpression("SequenceNumber", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.SequenceNumber = unmarshaller.Unmarshall(context);
                        continue;
                    }
                } 
           }

            return;
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context,SendMessageResponse response)
        {
            
            int originalDepth = context.CurrentDepth;
            int targetDepth = originalDepth + 1;
            
            if (context.IsStartOfDocument) 
               targetDepth += 2;
            
            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("MD5OfMessageBody", targetDepth))
                    {
                        response.MD5OfMessageBody = StringUnmarshaller.GetInstance().Unmarshall(context);
                            
                        continue;
                    }
                    if (context.TestExpression("MessageId", targetDepth))
                    {
                        response.MessageId = StringUnmarshaller.GetInstance().Unmarshall(context);
                            
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }
                            


            return;
        }
예제 #4
0
 public static void ValidateSendMessage(SendMessageRequest request, SendMessageResponse response)
 {
     if (request != null && response != null &&
         request.MessageBody != null && response.SendMessageResult != null &&
         !string.IsNullOrEmpty(request.MessageBody) &&
         !string.IsNullOrEmpty(response.SendMessageResult.MD5OfMessageBody))
     {
         AmazonSQSUtil.ValidateMD5(request.MessageBody, response.SendMessageResult.MD5OfMessageBody);
     }
 }
        private static void ValidateSendMessage(SendMessageRequest request, SendMessageResponse response)
        {
            if (request != null && response != null && request.MessageBody != null &&
                !string.IsNullOrEmpty(request.MessageBody) &&
                !string.IsNullOrEmpty(response.MD5OfMessageBody))
            {
                ValidateMD5(request.MessageBody, response.MD5OfMessageBody);
            }

            if (request != null && response != null &&
                request.MessageAttributes != null && request.MessageAttributes.Count > 0 &&
                !string.IsNullOrEmpty(response.MD5OfMessageAttributes))
            {
                ValidateMD5(request.MessageAttributes, response.MD5OfMessageAttributes);
            }

        }