/// <summary> /// Adds the value for specified month. /// </summary> /// <param name="instance"> The instance. </param> /// <param name="month"> The month. </param> /// <param name="value"> The value. </param> private static void AddValueForMonth(AnnualSolarPotential instance, Month month, int value) { var instanceType = instance.GetType(); var field = instanceType.GetField("_{0}Total".With(month.ToString().ToLower()), BindingFlags.NonPublic | BindingFlags.Instance); if (field == null) { throw new ArgumentException("field is null {0}".With(month.ToString())); } int currentValue; if (!int.TryParse(field.GetValue(instance).ToString(), out currentValue)) { throw new ArgumentException("Total value for {0} {1} would not parse to int.".With(field.Name, month.ToString())); } field.SetValue(instance, currentValue + value); }
public SolarPotential() { Duration = new AnnualSolarPotential(); Radiation = new AnnualSolarPotential(); }