Skip to content

Arithmomaniac/XmlOverrideBuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XmlOverrideBuilder

© 2016 Avi Levin Based on work © 2014 Ivan Krivyakov

This project is an XML serialization helper for .NET. It creates an XmlAttributeOverrides via a fluent interface.

This project is heavily based on OverrideXml, and the basic idea of how to use it is explained in Ivan's blog. I essentially just refactored the code to match more normal fluid pattterns, as I explain here. Here is how you would write the example he gives on his blog using this package:

XmlAttributeOverrides GetOverrides()
{
	return new XmlOverrideBuilder()
	    .Configure<Continent>(x => {
	        x.ForRoot().XmlRoot("continent");
	        x.ForMember(y => y.Name).XmlAttribute("name");
	        x.ForMember(y => y.Countries).XmlElement("state");
	    })
	    .Configure<Country>(x => {
	        x.ForMember(y => y.Name).XmlAttribute("name");
	        x.ForMember(y => y.Capital).XmlAttribute("capital");
	    })
	    .Commit();
}

About

Control XML serialization via a fluid XmlAttributeOverrides builder

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published