Пример #1
0
 public static Statement BuildStatement()
 {
     var customer = Rentals != null
         ? new Customer(CustomerName, Rentals)
         : new Customer(CustomerName);
     _statement = new Statement(customer);
     return _statement;
 }
Пример #2
0
 private string GetMoviesString(Statement statement)
 {
     string movies = null;
     foreach (var movie in statement.Movies)
     {
         movies += String.Format("\t {0} \t {1} {2}", movie.Key,
             movie.Value.ToString(CultureInfo.InvariantCulture), Environment.NewLine);
     }
     return movies;
 }
Пример #3
0
 public void GetStatement(Action<object> delegateWriter, Statement statement)
 {
     using (var stream = new MemoryStream())
     {
         var ser = new DataContractJsonSerializer(typeof(Statement));
         ser.WriteObject(stream, statement);
         stream.Position = 0;
         var sr = new StreamReader(stream);
         delegateWriter(sr.ReadToEnd());
     }
 }
Пример #4
0
        public void GetStatement(Action<object> delegateWriter, Statement statement)
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(Properties.Resources.StatementTemplate);
            var statementTemplate = xmlDocument.SelectSingleNode("statementTemplate");

            if (statementTemplate == null)
            {
                throw new InvalidDataException("statementTemplate");
            }
            Replace(statementTemplate, "CustomerName", statement.Name);
            Replace(statementTemplate, "TotalAmount", statement.TotalAmount.ToString(CultureInfo.InvariantCulture));
            Replace(statementTemplate, "FrequentRenterPoints",
                statement.FrequentRenterPoints.ToString(CultureInfo.InvariantCulture));
            Replace(statementTemplate, "Movies", GetMoviesString(statement));
            delegateWriter(statementTemplate.InnerText);
        }
Пример #5
0
 public void GetStatement(Action<object> write, Statement statement)
 {
     foreach (var keyValuePair in _statemnetFormatters)
     {
         var delegateWriter = keyValuePair.Value;
         var formater = keyValuePair.Key;
         formater.GetStatement(delegateWriter, statement);
     }
 }