public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var text = value as string; if (text != null) { TorqueUnit result; if (TorqueUnit.TryParse(text, out result)) { return(result); } var message = $"Could not convert the string '{text}' to an instance of TorqueUnit)"; throw new NotSupportedException(message); } return(base.ConvertFrom(context, culture, value)); }
/// <summary> /// Creates a new instance of <see cref="T:Gu.Units.Torque"/>. /// </summary> /// <param name="value"></param> /// <param name="unit"></param> public static Torque From(double value, TorqueUnit unit) { return(new Torque(unit.ToSiUnit(value))); }
public string ToString(string format, IFormatProvider formatProvider, TorqueUnit unit) { var quantity = unit.FromSiUnit(this.newtonMetres); return(string.Format("{0}{1}", quantity.ToString(format, formatProvider), unit.Symbol)); }
/// <summary> /// Initializes a new instance of <see cref="T:Gu.Units.Torque"/>. /// </summary> /// <param name="value"></param> /// <param name="unit"><see cref="T:Gu.Units.NewtonMetres"/>.</param> public Torque(double value, TorqueUnit unit) { this.newtonMetres = unit.ToSiUnit(value); }
public bool Equals(TorqueUnit other) { return(this.symbol == other.symbol); }
public static bool TryParse(string text, out TorqueUnit result) { return(UnitParser <TorqueUnit> .TryParse(text, out result)); }