public Customer Deserialize(SerializedData serializedData)
{
string standardData = serializedData.StandardData;
string name = Regex.Match(standardData, @"\b\w+\n", RegexOptions.Compiled).ToString().TrimEnd('\n');
var customer = new Customer(name);
var movieTitles = Regex.Matches(standardData, @"\t(.*?)\t", RegexOptions.Compiled);
var moviePrices = Regex.Matches(standardData, @"\t\d+[,.]?(\d+)?\n", RegexOptions.Compiled);
if (movieTitles.Count != moviePrices.Count)
{
throw new ArgumentException("data");
}
for (int i = 0; i < movieTitles.Count; ++i)
{
customer.Movies.Add(movieTitles[i].ToString().Trim('\t'), Convert.ToDouble(moviePrices[i].ToString().Trim('\t', '\n')));
}
string totalAmounAsString = Regex.Match(standardData, @" \d+[,.]?(\d+)?\n", RegexOptions.Compiled).ToString().TrimEnd('\n');
customer.TotalAmount = Convert.ToDouble(totalAmounAsString);
customer.FrequentRenterPoints = Convert.ToInt32(Regex.Match(standardData, @" (\d+) ", RegexOptions.Compiled).ToString());
return customer;
}