Class PercentCalculator
- Namespace
- SunamoPercentCalculator
- Assembly
- SunamoPercentCalculator.dll
Calculator for percentage distribution. Typically called multiple times via DonePartially().
public class PercentCalculator
- Inheritance
-
PercentCalculator
- Inherited Members
- Extension Methods
Constructors
PercentCalculator(double)
Creates a new instance of PercentCalculator with the specified overall sum.
public PercentCalculator(double overallSum)
Parameters
overallSumdoubleThe total sum representing 100%.
Properties
Last
The last computed percentage value.
public double Last { get; set; }
Property Value
OnePercent
The value of one percent relative to the overall sum.
public double OnePercent { get; set; }
Property Value
OverallSum
The overall sum representing 100%.
public double OverallSum { get; set; }
Property Value
PercentCalculatorType
The type of this class, for reflection purposes.
public static Type PercentCalculatorType { get; set; }
Property Value
Methods
AddOnePercent()
Adds one percent to the accumulated Last value.
public void AddOnePercent()
Create(double)
Creates a new PercentCalculator instance with the specified overall sum.
public static PercentCalculator Create(double overallSum)
Parameters
overallSumdoubleThe total sum representing 100%.
Returns
- PercentCalculator
A new PercentCalculator instance.
PercentFor(double, bool)
Calculates the percentage for a given value relative to the overall sum.
public int PercentFor(double value, bool isLast)
Parameters
valuedoubleThe value to calculate the percentage for.
isLastboolWhether this is the last calculation, triggering adjustment to ensure total equals 100%.
Returns
- int
The calculated percentage as an integer.
ResetComputedSum()
Resets the computed sum to zero. Automatically called by PercentFor when isLast is true.
public void ResetComputedSum()