Ejemplo n.º 1
0
        public static void FillPropertiesFromXmlValues(this IXmlEntity entity, Type xmlMappedAttributeType, string xmlValues)
        {
            var document = xmlValues == null ? new XDocument(new XElement(RootNodename)) : XDocument.Parse(xmlValues);

            var properties = entity.GetXmlMappedProperties(xmlMappedAttributeType);

            foreach (var propertyInfo in properties)
            {
                propertyInfo.SetValue(entity, document.Get(propertyInfo));
            }
        }
Ejemplo n.º 2
0
        public static string GetXmlValuesFromProperties(this IXmlEntity entity, Type xmlMappedAttributeType)
        {
            var       properties = entity.GetXmlMappedProperties(xmlMappedAttributeType);
            XDocument document   = new XDocument(new XElement(RootNodename));

            foreach (var propertyInfo in properties)
            {
                document.Set(entity, propertyInfo);
            }
            var rootNode = document.Root;

            if (rootNode == null || !rootNode.Elements().Any())
            {
                return(null);
            }
            return(document.ToString(SaveOptions.DisableFormatting));
        }