public void ReadElement(SimpleElementAttribute attribute, object reader,
                                object receiver, ReadSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            if (attribute.IsMultiple)
            {
                QueryStringValue itemValue = GetValue(reader, info.LocalName);
                if (itemValue == null)
                {
                    return;
                }
                var itemValues = itemValue.Values;
                if (itemValues == null)
                {
                    return;
                }

                foreach (var item in itemValues)
                {
                    object objValue = SerializerUtil.GetPropertyObject(receiver, settings, info,
                                                                       item, attribute.AutoTrim);
                    SerializerUtil.AddElementValue(attribute, receiver, info, objValue);
                }
            }
            else
            {
                SerializerUtil.SetObjectValue(receiver, settings, info,
                                              GetValue(reader, info.LocalName).ConvertToString(), attribute.AutoTrim);
            }
        }
Example #2
0
        public void ReadComplexElement(SimpleComplexElementAttribute attribute, object reader,
                                       object receiver, ReadSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            XmlReader xml      = reader.Convert <XmlReader>();
            string    value    = ReadComplexContent(xml, info.QName);
            object    objValue = SerializerUtil.GetPropertyObject(receiver, settings, info, value, false);

            SerializerUtil.AddElementValue(attribute, receiver, info, objValue);
        }
Example #3
0
        public void ReadComplexElement(SimpleComplexElementAttribute attribute, object reader,
                                       object receiver, ReadSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            XElement current = XElementData.GetCurrent(reader);

            string value    = current.HasElements ? current.FirstNode.ToString() : null;
            object objValue = SerializerUtil.GetPropertyObject(receiver, settings, info, value, false);

            SerializerUtil.AddElementValue(attribute, receiver, info, objValue);
        }
Example #4
0
        public void ReadElement(SimpleElementAttribute attribute, object reader,
                                object receiver, ReadSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            XmlReader xml      = reader.Convert <XmlReader>();
            string    value    = ReadString(xml);
            object    objValue = SerializerUtil.GetPropertyObject(receiver, settings, info,
                                                                  value, attribute.AutoTrim);

            SerializerUtil.AddElementValue(attribute, receiver, info, objValue);
        }
Example #5
0
        public void ReadElement(SimpleElementAttribute attribute, object reader,
                                object receiver, ReadSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            XElement current = XElementData.GetCurrent(reader);

            string value    = current.Value;
            object objValue = SerializerUtil.GetPropertyObject(receiver, settings, info,
                                                               value, attribute.AutoTrim);

            SerializerUtil.AddElementValue(attribute, receiver, info, objValue);
        }
Example #6
0
        public void ReadObjectElement(ObjectElementAttribute attribute, object reader,
                                      object receiver, ReadSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            Type   objectType = info.ObjectType;
            object subObject  = attribute.UseConstructor ? ObjectUtil.CreateObjectWithCtor(objectType)
                : ObjectUtil.CreateObject(objectType);

            Read(reader, subObject, info.ModelName, settings, info.QName, null);
            SerializerUtil.SetParent(receiver, subObject);

            SerializerUtil.AddElementValue(attribute, receiver, info, subObject);
        }
Example #7
0
        public void ReadElement(SimpleElementAttribute attribute, object reader, object receiver,
                                ReadSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            if (attribute.IsMultiple)
            {
                throw new NotSupportedException();
            }

            string value    = GetValue(reader, info.LocalName);
            object objValue = SerializerUtil.GetPropertyObject(receiver, settings, info,
                                                               value, attribute.AutoTrim);

            SerializerUtil.AddElementValue(attribute, receiver, info, objValue);
        }
Example #8
0
        public void ReadObjectElement(ObjectElementAttribute attribute, object reader, object receiver,
                                      ReadSettings settings, ObjectPropertyInfo info, object serializerData)
        {
            if (attribute.IsMultiple)
            {
                throw new NotSupportedException();
            }

            string xml = GetValue(reader, info.LocalName);

            if (string.IsNullOrEmpty(xml))
            {
                SerializerUtil.AddElementValue(attribute, receiver, info, null);
            }
            else
            {
                Type   objectType = info.ObjectType;
                object subObject  = attribute.UseConstructor ? ObjectUtil.CreateObjectWithCtor(objectType)
                    : ObjectUtil.CreateObject(objectType);
                subObject.ReadXml(xml, settings, QName.ToolkitNoNS);
                SerializerUtil.AddElementValue(attribute, receiver, info, subObject);
                SerializerUtil.SetParent(receiver, subObject);
            }
        }