public string ToString(string format, IFormatProvider formatProvider, TemperatureUnit unit) { var quantity = unit.FromSiUnit(this.kelvin); return(string.Format("{0}{1}", quantity.ToString(format, formatProvider), unit.Symbol)); }
/// <summary> /// Initializes a new instance of <see cref="T:Gu.Units.Temperature"/>. /// </summary> /// <param name="value"></param> /// <param name="unit"><see cref="T:Gu.Units.Kelvin"/>.</param> public Temperature(double value, TemperatureUnit unit) { this.kelvin = unit.ToSiUnit(value); }
/// <summary> /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.TemperatureUnit"/> object. /// </summary> /// <param name="other">An instance of <see cref="Gu.Units.TemperatureUnit"/> object to compare with this instance.</param> /// <returns> /// true if <paramref name="other"/> represents the same TemperatureUnit as this instance; otherwise, false. /// </returns> public bool Equals(TemperatureUnit other) { return(this.symbol == other.symbol); }
/// <summary> /// Creates a new instance of <see cref="T:Gu.Units.Temperature"/>. /// </summary> /// <param name="value"></param> /// <param name="unit"></param> public static Temperature From(double value, TemperatureUnit unit) { return(new Temperature(unit.ToSiUnit(value))); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.TemperatureUnit"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.TemperatureUnit"/></param> /// <param name="result">The parsed <see cref="TemperatureUnit"/></param> /// <returns>True if an instance of <see cref="TemperatureUnit"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, out TemperatureUnit result) { return(UnitParser <TemperatureUnit> .TryParse(text, out result)); }