BO4E.Extensions/BusinessObjects/Energiemenge/EnergiemengeExtension.cs
/// <summary>
///     normalise energiemenge-&gt;energieverbrauch consumption values to a given <paramref name="target" /> value
/// </summary>
/// <param name="em">Energiemenge</param>
/// <param name="target">normalising constant (1.0 by default)</param>
/// <returns>new Energiemenge object with normalised consumption values</returns>
normalise energiemenge->energieverbrauch consumption values to a given  value
normalise energiemenge - > energieverbrauch consumption values to a given value
public static BO.Energiemenge Normalise(this BO.Energiemenge em, decimal target = 1.0M)
        {
            using (MiniProfiler.Current.Step(nameof(Normalise)))
            {
                BO.Energiemenge result;
                decimal scalingFactor;
                Tuple<decimal, Mengeneinheit> totalConsumption;
                using (MiniProfiler.Current.Step("Calculating total consumption and normalisation factor."))
                {
                    totalConsumption = em.GetTotalConsumption();
                    result = em.DeepClone();
                    if (totalConsumption.Item1 != 0.0M)
                        scalingFactor = target / totalConsumption.Item1;
                    else
                        scalingFactor = 0.0M;
                }
                using (MiniProfiler.Current.Step("Parallelised normalising of all values."))
                {
                    Parallel.ForEach(result.Energieverbrauch.Where(v => v.Einheit == totalConsumption.Item2),
                        v => { v.Wert = scalingFactor * v.Wert; });
                }
                return result;
            }
        }
public static BO . Energiemenge Normalise ( this BO . Energiemenge em , decimal target = 1.0M ) { using ( MiniProfiler . Current . Step ( nameof ( Normalise ) ) ) { BO . Energiemenge result ; decimal scalingFactor ; Tuple < decimal , Mengeneinheit > totalConsumption ; using ( MiniProfiler . Current . Step ( " " ) ) { totalConsumption = em . GetTotalConsumption ( ) ; result = em . DeepClone ( ) ; if ( totalConsumption . Item1 != 0.0M ) scalingFactor = target / totalConsumption . Item1 ; else scalingFactor = 0.0M ; } using ( MiniProfiler . Current . Step ( " " ) ) { Parallel . ForEach ( result . Energieverbrauch . Where ( v => v . Einheit == totalConsumption . Item2 ) , v => { v . Wert = scalingFactor * v . Wert ; } ) ; } return result ; } }
normalise energiemenge->energieverbrauch consumption values to a given  value
normalise energiemenge - > energieverbrauch consumption values to a given value
new Energiemenge object with normalised consumption values
new Energiemenge object with normalised consumption values
BO.Energiemenge
this
target
decimal
normalising constant (1.0 by default)
normalising constant ( 1 . 0 by default )
em
None