Beispiel #1
0
 /// <summary>
 /// Creates a new instance
 /// </summary>
 protected MultiPeriodField(IDictionary <string, decimal> store = null)
 {
     if (store != null)
     {
         Store = store.Select(kvp => new PeriodField(PeriodAsByte.Convert(kvp.Key), kvp.Value)).ToArray();
     }
 }
Beispiel #2
0
 /// <summary>
 /// Gets the value of the field for the requested period
 /// </summary>
 /// <param name="period">The requested period</param>
 /// <returns>The value for the period</returns>
 public decimal GetPeriodValue(string period)
 {
     return(GetPeriodValue(PeriodAsByte.Convert(period)));
 }
Beispiel #3
0
 /// <summary>
 /// Returns a string that represents the current object.
 /// </summary>
 /// <returns>
 /// A string that represents the current object.
 /// </returns>
 /// <filterpriority>2</filterpriority>
 public override string ToString()
 {
     return(StoreIsEmpty
         ? "" : string.Join(";", Store.Select(x => PeriodAsByte.Convert(x.Period) + ":" + x.Value)));
 }
Beispiel #4
0
 /// <summary>
 /// Sets the value of the field for the specified period
 /// </summary>
 /// <param name="period">The period</param>
 /// <param name="value">The value to be set</param>
 public void SetPeriodValue(string period, decimal value)
 {
     SetPeriodValue(PeriodAsByte.Convert(period), value);
 }
Beispiel #5
0
 /// <summary>
 /// Gets a dictionary of period names and values for the field
 /// </summary>
 /// <returns>The dictionary of period names and values</returns>
 public IReadOnlyDictionary <string, decimal> GetPeriodValues()
 {
     return(StoreIsEmpty
         ? new Dictionary <string, decimal>()
         : Store.ToDictionary(field => PeriodAsByte.Convert(field.Period), field => field.Value));
 }
Beispiel #6
0
 /// <summary>
 /// Gets the list of available period names for the field
 /// </summary>
 /// <returns>The list of periods</returns>
 public IEnumerable <string> GetPeriodNames()
 {
     return(StoreIsEmpty
         ? Enumerable.Empty <string>() : Store.Select(field => PeriodAsByte.Convert(field.Period)));
 }
Beispiel #7
0
 /// <summary>
 /// Returns true if the field contains a value for the requested period
 /// </summary>
 /// <param name="period">The requested period</param>
 public bool HasPeriodValue(string period) => !StoreIsEmpty && Store.Any(field => field.Period == PeriodAsByte.Convert(period));