Project DescriptionFast, powerfull and customisable tool for serialization to Apple's plist format.
Usage
- Any custom classes you wish to convert into a Property List must be marked as 'Serializable', or with PlistSerializableAttribute otherwise they will be ignored. Custom serialization by implementing IPlistSerializable or supplying writer with PlistValueWriterAttribute are also available
- When making a plist from custom classes any values you want included in the plist must be exposed through a Property (at least a getter) rather than public variables.
Example for System.Web.Mvc:
public class PlistResult : System.Web.Mvc.ActionResult
{
private readonly object _data;
public PlistResult(object data)
{
_data = data;
}
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "text/xml";
context.HttpContext.Response.ContentEncoding = Encoding.UTF8;
_data.WritePlistDocument(context.HttpContext.Response.OutputStream);
}
}
Control serialization with attributes
[Serializable]
public class TestModelItem
{
[PlistKey("Id")]
public Guid PersonId { get; set; }
public string Name { get; set; }
public int Age { get; set; }
[PlistIgnore]
public string Password { get; set; }
}
...
var val = new TestModelItem
{
PersonId = new Guid("C48912B2-6F4D-4C80-90D7-D97E238A26AC"),
Name = "John Smith",
Age = 40,
Password = "Secret"
};
var output = val.ToPlistDocument();
...
/*
Produces:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Id</key>
<string>c48912b2-6f4d-4c80-90d7-d97e238a26ac</string>
<key>Name</key>
<string>John Smith</string>
<key>Age</key>
<integer>40</integer>
</dict>
</plist>
*/