BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtension.cs
/// <summary>
///     Get consumption in given time reference frame.
/// </summary>
/// <param name="em">Energiemenge</param>
/// <param name="reference">time reference frame</param>
/// <returns>Tuple of consumption value and automatically determined unit of measurement</returns>
Get consumption in given time reference frame.
Get consumption in given time reference frame .
public static Tuple<decimal, Mengeneinheit> GetConsumption(this BO.Energiemenge em, ITimeRange reference)
        {
            using (MiniProfiler.Current.Step(nameof(GetConsumption)))
            {
                if (!IsPure(em)) throw new ArgumentException("The Energiemenge is not pure.");
                if (em.Energieverbrauch.Count == 0) return Tuple.Create(0.0M, Mengeneinheit.ANZAHL);
                ISet<Mengeneinheit> einheiten = new HashSet<Mengeneinheit>(em.Energieverbrauch.Select(x => x.Einheit));
                if (einheiten.Count > 1)
                    throw new NotImplementedException("Converting different units of same type is not supported yet.");
                var v = em.Energieverbrauch.First();
                var consumption = em.GetConsumption(reference, v.Wertermittlungsverfahren, v.Obiskennzahl, v.Einheit);
                return Tuple.Create(consumption, v.Einheit);
            }
        }
public static Tuple < decimal , Mengeneinheit > GetConsumption ( this BO . Energiemenge em , ITimeRange reference ) { using ( MiniProfiler . Current . Step ( nameof ( GetConsumption ) ) ) { if ( ! IsPure ( em ) ) throw new ArgumentException ( " " ) ; if ( em . Energieverbrauch . Count == 0 ) return Tuple . Create ( 0.0M , Mengeneinheit . ANZAHL ) ; ISet < Mengeneinheit > einheiten = new HashSet < Mengeneinheit > ( em . Energieverbrauch . Select ( x => x . Einheit ) ) ; if ( einheiten . Count > 1 ) throw new NotImplementedException ( " " ) ; var v = em . Energieverbrauch . First ( ) ; var consumption = em . GetConsumption ( reference , v . Wertermittlungsverfahren , v . Obiskennzahl , v . Einheit ) ; return Tuple . Create ( consumption , v . Einheit ) ; } }
Get consumption in given time reference frame.
Get consumption in given time reference frame .
// z.B. kWh und Wh oder Monat und Jahr... Die liefern IsPure==true.
Tuple of consumption value and automatically determined unit of measurement
Tuple of consumption value and automatically determined unit of measurement
BO.Energiemenge
this
reference
ITimeRange
time reference frame
time reference frame
em
None