Basic Serialization
Similar to the XmlSerializer, Blueprints can serialize and deserialize objects out-of-the-box. Take for instance the Configuration class below:
public class Configuration
{
public int Timeout { get; set; }
}
An instance of this class can be serialized as follows:
Configuration config = new Configuration();
config.Timeout = 5000;
using (Stream stream = File.Open("config.xml", FileMode.Create, FileAccess.Write))
{
Blueprint.Serialize(stream, config);
}
This would create an xml file with the following contents:
<Blueprint xmlns:blueprints="http://const.nl/blueprints" blueprints:type="MyApplication.Configuration, MyApplication">
<Timeout>5000</Timeout>
</Blueprint>
Deserialization is done in a similar fashion:
using (Stream stream = File.Open("config.xml", FileMode.Open, FileAccess.Read))
{
Configuration config = Blueprint.Deserialize(stream);
}