Beispiel #1
0
        /// <summary>
        /// Reads an instance of <see cref="Gu.Units.Momentum"/> from the <paramref name="reader"/>
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>An instance of  <see cref="Gu.Units.Momentum"/></returns>
        public static Momentum ReadFrom(XmlReader reader)
        {
            var v = new Momentum();

            v.ReadXml(reader);
            return(v);
        }
Beispiel #2
0
        /// <inheritdoc />
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var text = value as string;

            if (text != null)
            {
                return(Momentum.Parse(text, culture));
            }

            return(base.ConvertFrom(context, culture, value));
        }
Beispiel #3
0
        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 Momentum(XmlConvert.ToDouble(attribute), MomentumUnit.NewtonSecond);
            reader.ReadStartElement();
        }
Beispiel #4
0
 /// <summary>
 /// Multiplies <paramref name="left"/> with <paramref name="right"/>
 /// </summary>
 /// <param name="left">The left value</param>
 /// <param name="right">The right value</param>
 /// <returns>The <see cref="Momentum"/> that is the result from the multiplication.</returns>
 public static Momentum operator *(MassFlow left, Length right)
 {
     return(Momentum.FromNewtonSecond(left.kilogramsPerSecond * right.metres));
 }
Beispiel #5
0
 /// <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="Momentum"/> that is the result from the division.</returns>
 public static Momentum operator /(MassFlow left, Wavenumber right)
 {
     return(Momentum.FromNewtonSecond(left.kilogramsPerSecond / right.reciprocalMetres));
 }
Beispiel #6
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Momentum"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Momentum as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Momentum"/> 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(Momentum other, Momentum tolerance)
 {
     Ensure.GreaterThan(tolerance.newtonSecond, 0, nameof(tolerance));
     return(Math.Abs(this.newtonSecond - other.newtonSecond) < tolerance.newtonSecond);
 }
Beispiel #7
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Momentum"/> object.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Momentum as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Momentum"/> object to compare with this instance.</param>
 public bool Equals(Momentum other)
 {
     return(this.newtonSecond.Equals(other.newtonSecond));
 }
Beispiel #8
0
 /// <summary>
 /// Compares this instance to a specified <see cref="Gu.Units.Momentum"/> 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.Momentum"/> 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.Momentum"/> object to compare to this instance.</param>
 public int CompareTo(Momentum quantity)
 {
     return(this.newtonSecond.CompareTo(quantity.newtonSecond));
 }
 /// <summary>
 /// Multiplies <paramref name="left"/> with <paramref name="right"/>
 /// </summary>
 /// <param name="left">The left value</param>
 /// <param name="right">The right value</param>
 /// <returns>The <see cref="Momentum"/> that is the result from the multiplication.</returns>
 public static Momentum operator *(AreaDensity left, VolumetricFlow right)
 {
     return(Momentum.FromNewtonSecond(left.kilogramsPerSquareMetre * right.cubicMetresPerSecond));
 }
Beispiel #10
0
 /// <summary>
 /// Creates an instance of <see cref="Gu.Units.Momentum"/> from its string representation
 /// </summary>
 /// <param name="text">The string representation of the <see cref="Gu.Units.Momentum"/></param>
 /// <param name="styles">Specifies the <see cref="NumberStyles"/> to be used.</param>
 /// <param name="result">The parsed <see cref="Momentum"/></param>
 /// <returns>True if an instance of <see cref="Momentum"/> could be parsed from <paramref name="text"/></returns>
 public static bool TryParse(string text, NumberStyles styles, out Momentum result)
 {
     return(QuantityParser.TryParse <MomentumUnit, Momentum>(text, From, styles, CultureInfo.CurrentCulture, out result));
 }
Beispiel #11
0
 /// <summary>
 /// Multiplies <paramref name="left"/> with <paramref name="right"/>
 /// </summary>
 /// <param name="left">The left value</param>
 /// <param name="right">The right value</param>
 /// <returns>The <see cref="Momentum"/> that is the result from the multiplication.</returns>
 public static Momentum operator *(Speed left, Mass right)
 {
     return(Momentum.FromNewtonSecond(left.metresPerSecond * right.kilograms));
 }
Beispiel #12
0
 public static Momentum operator /(Force left, Frequency right)
 {
     return(Momentum.FromNewtonSecond(left.newtons / right.hertz));
 }
Beispiel #13
0
 public static Momentum operator *(Force left, Time right)
 {
     return(Momentum.FromNewtonSecond(left.newtons * right.seconds));
 }
Beispiel #14
0
 /// <summary>
 /// Multiplies <paramref name="left"/> with <paramref name="right"/>
 /// </summary>
 /// <param name="left">The left value</param>
 /// <param name="right">The right value</param>
 /// <returns>The <see cref="Momentum"/> that is the result from the multiplication.</returns>
 public static Momentum operator *(Mass left, Speed right)
 {
     return(Momentum.FromNewtonSecond(left.kilograms * right.metresPerSecond));
 }
Beispiel #15
0
 /// <summary>
 /// Creates an instance of <see cref="Gu.Units.Momentum"/> from its string representation
 /// </summary>
 /// <param name="text">The string representation of the <see cref="Gu.Units.Momentum"/></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="Momentum"/></param>
 /// <returns>True if an instance of <see cref="Momentum"/> could be parsed from <paramref name="text"/></returns>
 public static bool TryParse(string text, NumberStyles styles, IFormatProvider provider, out Momentum result)
 {
     return(QuantityParser.TryParse <MomentumUnit, Momentum>(text, From, styles, provider, out result));
 }
Beispiel #16
0
 /// <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="Momentum"/> that is the result from the division.</returns>
 public static Momentum operator /(Energy left, Speed right)
 {
     return(Momentum.FromNewtonSecond(left.joules / right.metresPerSecond));
 }
Beispiel #17
0
 /// <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="Momentum"/> that is the result from the division.</returns>
 public static Momentum operator /(Power left, Acceleration right)
 {
     return(Momentum.FromNewtonSecond(left.watts / right.metresPerSecondSquared));
 }