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