예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 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));
 }
예제 #4
0
 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));
 }