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