/// <summary> /// Reads an instance of <see cref="Gu.Units.Unitless"/> from the <paramref name="reader"/> /// </summary> /// <param name="reader"></param> /// <returns>An instance of <see cref="Gu.Units.Unitless"/></returns> public static Unitless ReadFrom(XmlReader reader) { var v = new Unitless(); v.ReadXml(reader); return(v); }
/// <inheritdoc /> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var text = value as string; if (text != null) { return(Unitless.Parse(text, culture)); } return(base.ConvertFrom(context, culture, value)); }
public void ReadXml(XmlReader reader) { reader.MoveToContent(); var attribute = reader.GetAttribute("Value"); if (attribute is null) { throw new XmlException($"Could not find attribute named: Value"); } this = new Unitless(XmlConvert.ToDouble(attribute), UnitlessUnit.Scalar); reader.ReadStartElement(); }
/// <summary> /// Divides <paramref name="left"/> by <paramref name="right"/> /// </summary> /// <param name="left">The left value</param> /// <param name="right">The right value</param> /// <returns>The <see cref="Unitless"/> that is the result from the division.</returns> public static Unitless operator /(Angle left, AnglePerUnitless right) { return(Unitless.FromScalar(left.radians / right.radiansPerUnitless)); }
public static Unitless operator /(Force left, ForcePerUnitless right) { return(Unitless.FromScalar(left.newtons / right.newtonsPerUnitless)); }
/// <summary> /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Unitless"/> object within the given tolerance. /// </summary> /// <returns> /// true if <paramref name="other"/> represents the same Unitless as this instance; otherwise, false. /// </returns> /// <param name="other">An instance of <see cref="Gu.Units.Unitless"/> object to compare with this instance.</param> /// <param name="tolerance">The maximum difference for being considered equal. Must be greater than zero.</param> public bool Equals(Unitless other, Unitless tolerance) { Ensure.GreaterThan(tolerance.scalar, 0, nameof(tolerance)); return(Math.Abs(this.scalar - other.scalar) < tolerance.scalar); }
/// <summary> /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Unitless"/> object. /// </summary> /// <returns> /// true if <paramref name="other"/> represents the same Unitless as this instance; otherwise, false. /// </returns> /// <param name="other">An instance of <see cref="Gu.Units.Unitless"/> object to compare with this instance.</param> public bool Equals(Unitless other) { return(this.scalar.Equals(other.scalar)); }
/// <summary> /// Compares this instance to a specified <see cref="Gu.Units.Unitless"/> object and returns an integer that indicates whether this <paramref name="quantity"/> is smaller than, equal to, or greater than the <see cref="Gu.Units.Unitless"/> object. /// </summary> /// <returns> /// A signed number indicating the relative quantitys of this instance and <paramref name="quantity"/>. /// Value /// Description /// A negative integer /// This instance is smaller than <paramref name="quantity"/>. /// Zero /// This instance is equal to <paramref name="quantity"/>. /// A positive integer /// This instance is larger than <paramref name="quantity"/>. /// </returns> /// <param name="quantity">An instance of <see cref="Gu.Units.Unitless"/> object to compare to this instance.</param> public int CompareTo(Unitless quantity) { return(this.scalar.CompareTo(quantity.scalar)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.Unitless"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.Unitless"/></param> /// <param name="styles">Specifies the <see cref="NumberStyles"/> to be used.</param> /// <param name="provider">Specifies the formatProvider to be used.</param> /// <param name="result">The parsed <see cref="Unitless"/></param> /// <returns>True if an instance of <see cref="Unitless"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, NumberStyles styles, IFormatProvider provider, out Unitless result) { return(QuantityParser.TryParse <UnitlessUnit, Unitless>(text, From, styles, provider, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.Unitless"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.Unitless"/></param> /// <param name="styles">Specifies the <see cref="NumberStyles"/> to be used.</param> /// <param name="result">The parsed <see cref="Unitless"/></param> /// <returns>True if an instance of <see cref="Unitless"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, NumberStyles styles, out Unitless result) { return(QuantityParser.TryParse <UnitlessUnit, Unitless>(text, From, styles, CultureInfo.CurrentCulture, out result)); }
public static Unitless operator *(double left, UnitlessUnit right) { return(Unitless.From(left, right)); }
/// <summary> /// Divides <paramref name="left"/> by <paramref name="right"/> /// </summary> /// <param name="left">The left value</param> /// <param name="right">The right value</param> /// <returns>The <see cref="Unitless"/> that is the result from the division.</returns> public static Unitless operator /(Length left, LengthPerUnitless right) { return(Unitless.FromScalar(left.metres / right.metresPerUnitless)); }