public ScaleBuilder(UnitConfiguration config, UnitMeta rootUnit) { this.config = config; precedingUnit = rootUnit; if (rootUnit.PhysicalUnit.IsDimensionless()) { throw new InvalidOperationException("The unit you start with should be associated with a physical unit to start a scale."); } }
IUnitScale IUnitScale.To(Unit singleUnit, int scale) { var newUnit = config.Unit(singleUnit) .IsPhysicalUnit(precedingUnit.PhysicalUnit) .ConvertValueBased(precedingUnit.Unit, v => v * scale, v => v / scale); ((IUnitMetaConfig)precedingUnit).ConvertValueBased(singleUnit, v => v / scale, v => v * scale); precedingUnit = (UnitMeta)newUnit; return(this); }