public bool Deserialize(XmlReader reader, IXRoadSerializable dtoObject, IXmlTemplateNode templateNode, XRoadMessage message) { if (message.EnableFiltering && !filters.Contains(message.FilterName)) { reader.ConsumeUnusedElement(); return(false); } XName typeAttribute; if (typeMap.Definition.IsAnonymous && !(typeMap is IArrayTypeMap) && (typeAttribute = reader.GetTypeAttributeValue()) != null) { throw new UnknownTypeException($"Expected anonymous type, but `{typeAttribute}` was given.", Definition, typeMap.Definition, typeAttribute); } var concreteTypeMap = (typeMap.Definition.IsInheritable ? serializer.GetTypeMapFromXsiType(reader, Definition) : null) ?? typeMap; var propertyValue = concreteTypeMap.Deserialize(reader, templateNode, Definition.Content, message); if (propertyValue == null) { return(true); } setValueMethod(dtoObject, propertyValue); return(true); }
public bool Deserialize(XmlReader reader, IXRoadSerializable dtoObject, IXmlTemplateNode templateNode, XRoadMessage message) { if (message.EnableFiltering && !filters.Contains(message.FilterName)) { reader.ConsumeUnusedElement(); return(false); } string typeAttribute; if (typeMap.Definition.IsAnonymous && !(typeMap is IArrayTypeMap) && (typeAttribute = reader.GetAttribute("type", NamespaceConstants.XSI)) != null) { throw XRoadException.InvalidQuery($"Expected anonymous type, but `{typeAttribute}` was given."); } var concreteTypeMap = (typeMap.Definition.IsInheritable ? serializerCache.GetTypeMapFromXsiType(reader) : null) ?? typeMap; var propertyValue = concreteTypeMap.Deserialize(reader, templateNode, Definition, message); if (propertyValue == null) { return(true); } setValueMethod(dtoObject, propertyValue); return(true); }
private static IEnumerable <string> GetMissingRequiredPropertyNames(IXRoadSerializable dtoObject, IXmlTemplateNode templateNode, XRoadMessage message) { return(templateNode.ChildNames .Select(n => templateNode[n, message.Version]) .Where(n => n.IsRequired) .Where(n => !dtoObject.IsSpecified(n.Name)) .Select(n => n.Name)); }
private IEnumerable <PropertyDefinition> GetMissingRequiredProperties(IXRoadSerializable dtoObject, IXmlTemplateNode templateNode, XRoadMessage message) { return(templateNode.ChildNames .Select(n => templateNode[n, message.Version]) .Where(n => n.IsRequired) .Where(n => !dtoObject.IsSpecified(n.Name)) .Select(n => deserializationPropertyMaps[n.Name].Definition)); }