Esempio n. 1
0
 /// <summary>
 /// Creates a new instance of the SIUnit class. SIUnit = factor * (SIBaseUnit ^ exponent) + offset
 /// </summary>
 /// <param name="baseUnit">The SI base unit.</param>
 /// <param name="factor">The factor with that the SIBaseUnit is multiplied.</param>
 /// <param name="exponent">The exponent to that the SIBaseUnit is exponentiated.</param>
 /// <param name="offset">The offset that is added to the SIBaseUnit.</param>
 public SIUnit(SIBaseUnit baseUnit, double?factor = null, double?exponent = null, double?offset = null)
     : this(baseUnit)
 {
     this.Factor   = factor;
     this.Exponent = exponent;
     this.Offset   = offset;
 }
Esempio n. 2
0
 public static string StringRepresentation(this SIBaseUnit unit)
 {
     if (!SIBaseUnitStringRepresentation.ContainsKey(unit))
     {
         throw new ArgumentOutOfRangeException(nameof(unit), unit, null);
     }
     return(SIBaseUnitStringRepresentation[unit]);
 }
Esempio n. 3
0
        internal static string GetXmlRepresentation(this SIBaseUnit baseUnit)
        {
            switch (baseUnit)
            {
            case SIBaseUnit.One:
            {
                return("1");
            }

            case SIBaseUnit.Meter:
            {
                return("m");
            }

            case SIBaseUnit.Kilogram:
            {
                return("kg");
            }

            case SIBaseUnit.Second:
            {
                return("s");
            }

            case SIBaseUnit.Ampere:
            {
                return("A");
            }

            case SIBaseUnit.Kelvin:
            {
                return("K");
            }

            case SIBaseUnit.Mol:
            {
                return("mol");
            }

            case SIBaseUnit.Candela:
            {
                return("cd");
            }

            default:
            {
                throw new ArgumentException("Specified SIBaseUnit value is not valid.");
            }
            }
        }
Esempio n. 4
0
 public SIUnitBuilder(SIBaseUnit siBaseUnit)
 {
     this.siUnit = new SIUnit(siBaseUnit);
 }
Esempio n. 5
0
 /// <summary>
 /// Creates a new instance of the SIUnit class.
 /// </summary>
 /// <param name="baseUnit">The SI base unit.</param>
 public SIUnit(SIBaseUnit baseUnit)
 {
     this.BaseUnit = baseUnit;
 }