Esempio n. 1
0
        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);
        }
        public IEnumerator <MessageElement> GetEnumerator()
        {
            if (m_enumeratorCreated)
            {
                throw new InvalidOperationException();
            }
            m_enumeratorCreated = true;
            while (m_reader.BaseStream.CanRead)
            {
                string name;
                object value;
                try
                {
                    VerifyLastStream();
                    name = m_reader.ReadString();
                    if (string.IsNullOrEmpty(name))
                    {
                        yield break;
                    }
                    if (StringComparer.OrdinalIgnoreCase.Compare(name, ".") == 0)
                    {
                        continue;
                    }
                    Type type = ProgressiveTypeDictionary.GetType(name);
                    if (type == null)
                    {
                        throw new NotImplementedException();
                    }
                    value = InternalReadValue(type);
                    goto IL_00c9;
                }
                catch (EndOfStreamException innerException)
                {
                    throw new IOException("end of stream", innerException);
                }
                catch (IOException)
                {
                    throw;
                }
                catch (Exception innerException2)
                {
                    throw new IOException("reader", innerException2);
                }
IL_00c9:
                yield return(new MessageElement(name, value));
            }
        }