Пример #1
0
        private void ReadStructContent(object obj, StructMapping mapping)
        {
            m_reader.MoveToContent();
            string name         = m_reader.Name;
            string namespaceURI = m_reader.NamespaceURI;

            ReadStructAttributes(obj, mapping);
            if (m_reader.IsEmptyElement)
            {
                m_reader.Skip();
                return;
            }
            m_reader.ReadStartElement();
            m_reader.MoveToContent();
            while (m_reader.NodeType != XmlNodeType.EndElement && m_reader.NodeType != 0)
            {
                string localName     = m_reader.LocalName;
                string namespaceURI2 = m_reader.NamespaceURI;
                namespaceURI2 = ((namespaceURI == namespaceURI2) ? string.Empty : namespaceURI2);
                MemberMapping memberMapping = mapping.GetElement(localName, namespaceURI2);
                Type          type          = null;
                if (memberMapping != null)
                {
                    type = memberMapping.Type;
                }
                else
                {
                    List <MemberMapping> typeNameElements = mapping.GetTypeNameElements();
                    if (typeNameElements != null)
                    {
                        bool flag = false;
                        for (int i = 0; i < typeNameElements.Count; i++)
                        {
                            memberMapping = typeNameElements[i];
                            XmlElementAttributes xmlElements = memberMapping.XmlAttributes.XmlElements;
                            if (base.XmlOverrides != null)
                            {
                                XmlAttributes xmlAttributes = base.XmlOverrides[obj.GetType()];
                                if (xmlAttributes == null)
                                {
                                    xmlAttributes = base.XmlOverrides[memberMapping.Type];
                                }
                                if (xmlAttributes != null && xmlAttributes.XmlElements != null)
                                {
                                    xmlElements = xmlAttributes.XmlElements;
                                }
                            }
                            foreach (XmlElementAttribute item in xmlElements)
                            {
                                if (item.ElementName == localName && item.Type != null)
                                {
                                    type = item.Type;
                                    flag = true;
                                    break;
                                }
                            }
                            if (flag)
                            {
                                break;
                            }
                        }
                    }
                }
                if (type != null)
                {
                    if (memberMapping.ChildAttributes != null)
                    {
                        foreach (MemberMapping childAttribute in memberMapping.ChildAttributes)
                        {
                            ReadChildAttribute(obj, mapping, childAttribute);
                        }
                    }
                    if (memberMapping.IsReadOnly)
                    {
                        if (!TypeMapper.IsPrimitiveType(type))
                        {
                            object value = memberMapping.GetValue(obj);
                            if (value != null)
                            {
                                ReadObjectContent(value, memberMapping, 0);
                            }
                            else
                            {
                                m_reader.Skip();
                            }
                        }
                        else
                        {
                            m_reader.Skip();
                        }
                    }
                    else
                    {
                        object obj2 = ReadObject(type, memberMapping, 0);
                        if (obj2 != null)
                        {
                            memberMapping.SetValue(obj, obj2);
                        }
                    }
                }
                else
                {
                    if (namespaceURI2 != string.Empty && m_validNamespaces.Contains(namespaceURI2))
                    {
                        IXmlLineInfo xmlLineInfo = (IXmlLineInfo)m_reader;
                        throw new XmlException(RDLValidatingReaderStrings.rdlValidationInvalidMicroVersionedElement(m_reader.Name, name, xmlLineInfo.LineNumber.ToString(CultureInfo.InvariantCulture.NumberFormat), xmlLineInfo.LinePosition.ToString(CultureInfo.InvariantCulture.NumberFormat)));
                    }
                    m_reader.Skip();
                }
                m_reader.MoveToContent();
            }
            m_reader.ReadEndElement();
        }