/// <summary> /// Reads an instance of <see cref="Gu.Units.Resistance"/> from the <paramref name="reader"/> /// </summary> /// <param name="reader"></param> /// <returns>An instance of <see cref="Gu.Units.Resistance"/></returns> public static Resistance ReadFrom(XmlReader reader) { var v = new Resistance(); v.ReadXml(reader); return(v); }
/// <devdoc> /// <para>Converts the given object to a <see cref='Gu.Units.Resistance'/> /// object.</para> /// </devdoc> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var text = value as string; if (text != null) { return(Resistance.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 Resistance(XmlConvert.ToDouble(attribute), ResistanceUnit.Ohms); reader.ReadStartElement(); }
public static Resistance operator *(Frequency left, Inductance right) { return(Resistance.FromOhms(left.hertz * right.henrys)); }
public static Resistance operator /(Inductance left, Time right) { return(Resistance.FromOhm(left.henrys / right.seconds)); }
public static Resistance operator *(double left, ResistanceUnit right) { return(Resistance.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="Resistance"/> that is the result from the division.</returns> public static Resistance operator /(Wavenumber left, Conductivity right) { return(Resistance.FromOhms(left.reciprocalMetres / right.siemensPerMetre)); }
/// <summary> /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Resistance"/> object within the given tolerance. /// </summary> /// <returns> /// true if <paramref name="other"/> represents the same Resistance as this instance; otherwise, false. /// </returns> /// <param name="other">An instance of <see cref="Gu.Units.Resistance"/> 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(Resistance other, Resistance tolerance) { Ensure.GreaterThan(tolerance.ohms, 0, nameof(tolerance)); return(Math.Abs(this.ohms - other.ohms) < tolerance.ohms); }
public static Resistance operator *(Inductance left, Frequency right) { return(Resistance.FromOhms(left.henrys * right.hertz)); }
/// <summary> /// Compares this instance to a specified <see cref="Gu.Units.Resistance"/> 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.Resistance"/> 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.Resistance"/> object to compare to this instance.</param> public int CompareTo(Resistance quantity) { return(this.ohms.CompareTo(quantity.ohms)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.Resistance"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.Resistance"/></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="Resistance"/></param> /// <returns>True if an instance of <see cref="Resistance"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, NumberStyles styles, IFormatProvider provider, out Resistance result) { return(QuantityParser.TryParse <ResistanceUnit, Resistance>(text, From, styles, provider, out result)); }
/// <summary> /// Creates an instance of <see cref="Gu.Units.Resistance"/> from its string representation /// </summary> /// <param name="text">The string representation of the <see cref="Gu.Units.Resistance"/></param> /// <param name="styles">Specifies the <see cref="NumberStyles"/> to be used.</param> /// <param name="result">The parsed <see cref="Resistance"/></param> /// <returns>True if an instance of <see cref="Resistance"/> could be parsed from <paramref name="text"/></returns> public static bool TryParse(string text, NumberStyles styles, out Resistance result) { return(QuantityParser.TryParse <ResistanceUnit, Resistance>(text, From, styles, CultureInfo.CurrentCulture, out result)); }
/// <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="Resistance"/> that is the result from the division.</returns> public static Resistance operator /(Time left, Capacitance right) { return(Resistance.FromOhms(left.seconds / right.farads)); }
public static Resistance operator /(double left, ElectricalConductance right) { return(Resistance.FromOhms(left / right.siemens)); }
/// <summary> /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Resistance"/> object. /// </summary> /// <returns> /// true if <paramref name="other"/> represents the same Resistance as this instance; otherwise, false. /// </returns> /// <param name="other">An instance of <see cref="Gu.Units.Resistance"/> object to compare with this instance.</param> public bool Equals(Resistance other) { return(this.ohms.Equals(other.ohms)); }
public static Resistance operator /(Voltage left, Current right) { return(Resistance.FromOhm(left.volts / right.amperes)); }
public static Resistance operator /(MagneticFlux left, ElectricCharge right) { return(Resistance.FromOhms(left.webers / right.coulombs)); }