Exemplo n.º 1
0
 public Records Load()
 {
     if (File.Exists(fileName))
     {
         var document = XDocument.Load(fileName);
         var data     = new Records();
         var records  = document.Root.Elements("record");
         foreach (var element in records)
         {
             data.Add(
                 new Record(
                     DateTime.Parse(
                         element.Attribute("datetime").Value,
                         CultureInfo.InvariantCulture),
                     float.Parse(
                         element.Attribute("amount").Value,
                         CultureInfo.InvariantCulture)));
         }
         return(data);
     }
     return(new Records());
 }
Exemplo n.º 2
0
 public double Sum(Records records) =>
 records.Sum(record => record.Amount);
Exemplo n.º 3
0
 public double Rate(Records records) =>
 records.Count() > 1
         ? (Duration(records).TotalSeconds > 0
             ? Sum(records) / Duration(records).TotalSeconds
             : 0.0f)
         : 0.0f;