BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtension.cs
/// <summary>
///     Returns the load in an intensive unit for a given point in time.
/// </summary>
/// <param name="em">Energiemenge</param>
/// <param name="me">an intensive unit (e.g. "kW")</param>
/// <param name="dt">point in time</param>
/// <returns>load if Energiemenge BO contains value for specified date time<paramref name="dt" />, null otherwise</returns>
Returns the load in an intensive unit for a given point in time.
Returns the load in an intensive unit for a given point in time .
public static decimal? GetLoad(this BO.Energiemenge em, Mengeneinheit me, DateTime dt)
        {
            if (!me.IsIntensive())
                throw new ArgumentException(
                    $"The Mengeneinheit {me} isn't intensive. Calculating the value for a specific point in time doesn't make sense.");
            decimal? result = null;
            foreach (var v in em.Energieverbrauch.Where(v => v.Startdatum <= dt && dt < v.Enddatum))
                if (result.HasValue)
                    result += v.Wert;
                else
                    result = v.Wert;
            return result;
        }
public static decimal ? GetLoad ( this BO . Energiemenge em , Mengeneinheit me , DateTime dt ) { if ( ! me . IsIntensive ( ) ) throw new ArgumentException ( $" The Mengeneinheit  { me }  isn't intensive. Calculating the value for a specific point in time doesn't make sense. " ) ; decimal ? result = null ; foreach ( var v in em . Energieverbrauch . Where ( v => v . Startdatum <= dt && dt < v . Enddatum ) ) if ( result . HasValue ) result += v . Wert ; else result = v . Wert ; return result ; }
Returns the load in an intensive unit for a given point in time.
Returns the load in an intensive unit for a given point in time .
load if Energiemenge BO contains value for specified date time, null otherwise
load if Energiemenge BO contains value for specified date time null otherwise
BO.Energiemenge
this
me
Mengeneinheit
an intensive unit
an intensive unit
dt
DateTime
point in time
point in time
em
None