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)); } }
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)); }