public bool PeekIsErrorResponse(out MessageElement error)
        {
            error = null;
            MessageElement messageElement = this.Peek();

            if (ProgressiveTypeDictionary.IsErrorMessageElement(messageElement))
            {
                error = messageElement;
                return(true);
            }
            return(false);
        }
 public override IEnumerator <ImageResponseMessageElement> GetEnumerator()
 {
     while (true)
     {
         MessageElement messageElement = this.Peek();
         this.m_hasCurrentElement = false;
         if (messageElement == null)
         {
             break;
         }
         ImageResponseMessageElement imageMessageElement = this.ReadImageResponseFromMessageElement(messageElement);
         yield return(imageMessageElement);
     }
 }
Ejemplo n.º 3
0
        public static bool IsErrorMessageElement(MessageElement messageElement)
        {
            if (messageElement == null)
            {
                return(false);
            }
            string name = messageElement.Name;

            if (!"serverError".Equals(name, StringComparison.Ordinal))
            {
                return("serverErrorCode".Equals(name, StringComparison.Ordinal));
            }
            return(true);
        }
        private ImageResponseMessageElement ReadImageResponseFromMessageElement(MessageElement messageElement)
        {
            Stream stream = messageElement.Value as Stream;

            if ("getExternalImagesResponse".Equals(messageElement.Name) && stream != null)
            {
                ImageResponseMessageElement imageResponseMessageElement = new ImageResponseMessageElement();
                using (BinaryReader reader = new BinaryReader(stream, MessageUtil.StringEncoding))
                {
                    imageResponseMessageElement.Read(reader);
                    return(imageResponseMessageElement);
                }
            }
            throw new InvalidOperationException("MessageElement is not an image response message element.");
        }