public BloomLinkArgs(string url)
{
if (!url.StartsWith(kBloomUrlPrefix))
throw new ArgumentException(String.Format("unrecognized BloomLinkArgs URL string: {0}", url));
// I think we can't use the standard HttpUtility because we are trying to stick to the .NET 4.0 Client profile
var queryData = url.Substring(kBloomUrlPrefix.Length);
var qparams = queryData.Split('&');
var parts = qparams[0].Split('=');
if (parts.Length != 2 || parts[0] != kOrderFile)
throw new ArgumentException(String.Format("badly formed BloomLinkArgs URL string: {0}", url));
OrderUrl = HttpUtilityFromMono.UrlDecode(parts[1]);
if (qparams.Length > 1 && qparams[1].StartsWith("title="))
Title = HttpUtilityFromMono.UrlDecode(qparams[1].Substring("title=".Length));
else
{
// Make up a title from the book order. This should be obsolete once all instances of Bloom Library
// are supplying titles.
var indexOfSlash = OrderUrl.LastIndexOf('/');
var bookOrder = OrderUrl.Substring(indexOfSlash + 1);
Title = Path.GetFileNameWithoutExtension(bookOrder);
}
}