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

            if (ProgressiveTypeDictionary.IsErrorMessageElement(messageElement))
            {
                error = messageElement;
                return(true);
            }
            return(false);
        }
        private Type VerifyType(string name, Type type)
        {
            Type type2 = ProgressiveTypeDictionary.GetType(name);

            if (type2 == null)
            {
                throw new NotImplementedException();
            }
            if (!type2.IsAssignableFrom(type))
            {
                throw new ArgumentException("wrong type", "value");
            }
            return(type2);
        }
Exemplo n.º 3
0
        public IEnumerator <MessageElement> GetEnumerator()
        {
            if (this.m_enumeratorCreated)
            {
                throw new InvalidOperationException();
            }
            this.m_enumeratorCreated = true;
            while (this.m_reader.BaseStream.CanRead)
            {
                string name;
                object value;
                try
                {
                    this.VerifyLastStream();
                    name = this.m_reader.ReadString();
                    if (string.IsNullOrEmpty(name))
                    {
                        yield break;
                    }
                    if (StringComparer.OrdinalIgnoreCase.Compare(name, ".") != 0)
                    {
                        Type type = ProgressiveTypeDictionary.GetType(name);
                        if (type == null)
                        {
                            throw new NotImplementedException();
                        }
                        value = this.InternalReadValue(type);
                        goto IL_00da;
                    }
                }
                catch (EndOfStreamException innerException)
                {
                    throw new IOException("end of stream", innerException);
                }
                catch (IOException)
                {
                    throw;
                }
                catch (Exception innerException2)
                {
                    throw new IOException("reader", innerException2);
                }
                continue;
IL_00da:
                yield return(new MessageElement(name, value));
            }
        }