예제 #1
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 Capacitance(XmlConvert.ToDouble(attribute), CapacitanceUnit.Farads);
            reader.ReadStartElement();
        }
 public static Capacitance operator *(double left, CapacitanceUnit right)
 {
     return(Capacitance.From(left, right));
 }
예제 #3
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Capacitance"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Capacitance as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Capacitance"/> 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(Capacitance other, Capacitance tolerance)
 {
     Ensure.GreaterThan(tolerance.farads, 0, nameof(tolerance));
     return(Math.Abs(this.farads - other.farads) < tolerance.farads);
 }
예제 #4
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Capacitance"/> object.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Capacitance as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Capacitance"/> object to compare with this instance.</param>
 public bool Equals(Capacitance other)
 {
     return(this.farads.Equals(other.farads));
 }
예제 #5
0
 /// <summary>
 /// Compares this instance to a specified <see cref="Gu.Units.Capacitance"/> 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.Capacitance"/> 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.Capacitance"/> object to compare to this instance.</param>
 public int CompareTo(Capacitance quantity)
 {
     return(this.farads.CompareTo(quantity.farads));
 }
예제 #6
0
 /// <summary>
 /// Creates an instance of <see cref="Gu.Units.Capacitance"/> from its string representation
 /// </summary>
 /// <param name="text">The string representation of the <see cref="Gu.Units.Capacitance"/></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="Capacitance"/></param>
 /// <returns>True if an instance of <see cref="Capacitance"/> could be parsed from <paramref name="text"/></returns>
 public static bool TryParse(string text, NumberStyles styles, IFormatProvider provider, out Capacitance result)
 {
     return(QuantityParser.TryParse <CapacitanceUnit, Capacitance>(text, From, styles, provider, out result));
 }
예제 #7
0
 /// <summary>
 /// Creates an instance of <see cref="Gu.Units.Capacitance"/> from its string representation
 /// </summary>
 /// <param name="text">The string representation of the <see cref="Gu.Units.Capacitance"/></param>
 /// <param name="styles">Specifies the <see cref="NumberStyles"/> to be used.</param>
 /// <param name="result">The parsed <see cref="Capacitance"/></param>
 /// <returns>True if an instance of <see cref="Capacitance"/> could be parsed from <paramref name="text"/></returns>
 public static bool TryParse(string text, NumberStyles styles, out Capacitance result)
 {
     return(QuantityParser.TryParse <CapacitanceUnit, Capacitance>(text, From, styles, CultureInfo.CurrentCulture, out result));
 }
예제 #8
0
 public static Capacitance operator *(ElectricalConductance left, Time right)
 {
     return(Capacitance.FromFarads(left.siemens * right.seconds));
 }
예제 #9
0
 public static Capacitance operator /(ElectricalConductance left, Frequency right)
 {
     return(Capacitance.FromFarads(left.siemens / right.hertz));
 }
예제 #10
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="Capacitance"/> that is the result from the division.</returns>
 public static Capacitance operator /(Time left, Resistance right)
 {
     return(Capacitance.FromFarads(left.seconds / right.ohms));
 }
 public static Capacitance operator /(ElectricCharge left, Voltage right)
 {
     return(Capacitance.FromFarads(left.coulombs / right.volts));
 }