Ejemplo n.º 1
0
        public Boolean TryGetCurrentMember(out XmlMemberInfo memberInfo)
        {
            if (this.XmlReader.ReadState != ReadState.Interactive)
            {
                throw new InvalidOperationException();
            }
            if (this.XmlReader.NodeType != XmlNodeType.Element)
            {
                throw new InvalidOperationException();
            }
            Contract.Ensures(
                (Contract.Result <Boolean>() && Contract.ValueAtReturn(out memberInfo) != null) ||
                (!Contract.Result <Boolean>() && Contract.ValueAtReturn(out memberInfo) == null));

            for (Int32 i = 0; i < this.Serializer.SerializableMembers.Count; i++)
            {
                XmlSerializableMember member = this.Serializer.SerializableMembers[i];

                Type memberType;
                if (member.MemberInfo.TryGetMemberTypeByName(this.XmlReader.LocalName, out memberType))
                {
                    memberInfo = member.MemberInfo;
                    return(true);
                }
            }

            memberInfo = null;
            return(false);
        }
Ejemplo n.º 2
0
        private Object ReadMemberContent(XmlMemberInfo memberInfo, IEnumerable <XmlItemDefAttribute> itemDefAttributeOverrides = null)
        {
            XmlItemDefAttributeCollection itemDefAttributes = new XmlItemDefAttributeCollection(memberInfo.ItemDefAttributes);

            if (itemDefAttributeOverrides != null)
            {
                itemDefAttributes.AddRange(itemDefAttributeOverrides);
            }

            return(this.ReadElementContent(memberInfo.Type, itemDefAttributes));
        }
Ejemplo n.º 3
0
        public T ReadMemberContent <T>(XmlMemberInfo memberInfo, IEnumerable <XmlItemDefAttribute> itemDefAttributeOverrides = null)
        {
            if (this.XmlReader.ReadState != ReadState.Interactive)
            {
                throw new InvalidOperationException();
            }
            if (this.XmlReader.NodeType != XmlNodeType.Element)
            {
                throw new InvalidOperationException();
            }

            return((T)this.ReadMemberContent(memberInfo, itemDefAttributeOverrides));
        }