コード例 #1
0
ファイル: SymbolAndPower.cs プロジェクト: pockees/Gu.Units
 public SymbolAndPower(string symbol, int power)
 {
     Ensure.NotNullOrEmpty(symbol, nameof(symbol));
     Ensure.LessThan(power, 5, nameof(power));
     Ensure.GreaterThan(power, -5, nameof(power));
     // not sure about throwing here but I think it means something is wrong more often.
     this.Symbol = symbol;
     this.Power  = power;
 }
コード例 #2
0
 public bool Equals(AnglePerUnitless other, AnglePerUnitless tolerance)
 {
     Ensure.GreaterThan(tolerance.radiansPerUnitless, 0, nameof(tolerance));
     return(Math.Abs(this.radiansPerUnitless - other.radiansPerUnitless) < tolerance.radiansPerUnitless);
 }
コード例 #3
0
ファイル: Energy.generated.cs プロジェクト: forki/Gu.Units
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Energy"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Energy as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Energy"/> 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(Energy other, Energy tolerance)
 {
     Ensure.GreaterThan(tolerance.joules, 0, nameof(tolerance));
     return(Math.Abs(this.joules - other.joules) < tolerance.joules);
 }
コード例 #4
0
 public bool Equals(MagneticFieldStrength other, MagneticFieldStrength tolerance)
 {
     Ensure.GreaterThan(tolerance.teslas, 0, nameof(tolerance));
     return(Math.Abs(this.teslas - other.teslas) < tolerance.teslas);
 }
コード例 #5
0
 public bool Equals(Illuminance other, Illuminance tolerance)
 {
     Ensure.GreaterThan(tolerance.lux, 0, nameof(tolerance));
     return(Math.Abs(this.lux - other.lux) < tolerance.lux);
 }
コード例 #6
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.MassFlow"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same MassFlow as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.MassFlow"/> 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(MassFlow other, MassFlow tolerance)
 {
     Ensure.GreaterThan(tolerance.kilogramsPerSecond, 0, nameof(tolerance));
     return(Math.Abs(this.kilogramsPerSecond - other.kilogramsPerSecond) < tolerance.kilogramsPerSecond);
 }
コード例 #7
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);
 }
コード例 #8
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Flexibility"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Flexibility as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Flexibility"/> 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(Flexibility other, Flexibility tolerance)
 {
     Ensure.GreaterThan(tolerance.metresPerNewton, 0, nameof(tolerance));
     return(Math.Abs(this.metresPerNewton - other.metresPerNewton) < tolerance.metresPerNewton);
 }
コード例 #9
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.AmountOfSubstance"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same AmountOfSubstance as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.AmountOfSubstance"/> 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(AmountOfSubstance other, AmountOfSubstance tolerance)
 {
     Ensure.GreaterThan(tolerance.moles, 0, nameof(tolerance));
     return(Math.Abs(this.moles - other.moles) < tolerance.moles);
 }
コード例 #10
0
 public bool Equals(Force other, Force tolerance)
 {
     Ensure.GreaterThan(tolerance.newtons, 0, nameof(tolerance));
     return(Math.Abs(this.newtons - other.newtons) < tolerance.newtons);
 }
コード例 #11
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Wavenumber"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Wavenumber as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Wavenumber"/> 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(Wavenumber other, Wavenumber tolerance)
 {
     Ensure.GreaterThan(tolerance.reciprocalMetres, 0, nameof(tolerance));
     return(Math.Abs(this.reciprocalMetres - other.reciprocalMetres) < tolerance.reciprocalMetres);
 }
コード例 #12
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.AngularAcceleration"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same AngularAcceleration as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.AngularAcceleration"/> 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(AngularAcceleration other, AngularAcceleration tolerance)
 {
     Ensure.GreaterThan(tolerance.radiansPerSecondSquared, 0, nameof(tolerance));
     return(Math.Abs(this.radiansPerSecondSquared - other.radiansPerSecondSquared) < tolerance.radiansPerSecondSquared);
 }
コード例 #13
0
ファイル: Jerk.generated.cs プロジェクト: pockees/Gu.Units
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Jerk"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Jerk as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Jerk"/> 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(Jerk other, Jerk tolerance)
 {
     Ensure.GreaterThan(tolerance.metresPerSecondCubed, 0, nameof(tolerance));
     return(Math.Abs(this.metresPerSecondCubed - other.metresPerSecondCubed) < tolerance.metresPerSecondCubed);
 }
コード例 #14
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Temperature"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Temperature as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Temperature"/> 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(Temperature other, Temperature tolerance)
 {
     Ensure.GreaterThan(tolerance.kelvin, 0, nameof(tolerance));
     return(Math.Abs(this.kelvin - other.kelvin) < tolerance.kelvin);
 }
コード例 #15
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Stiffness"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Stiffness as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Stiffness"/> 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(Stiffness other, Stiffness tolerance)
 {
     Ensure.GreaterThan(tolerance.newtonsPerMetre, 0, nameof(tolerance));
     return(Math.Abs(this.newtonsPerMetre - other.newtonsPerMetre) < tolerance.newtonsPerMetre);
 }
コード例 #16
0
 public bool Equals(ElectricalConductance other, ElectricalConductance tolerance)
 {
     Ensure.GreaterThan(tolerance.siemens, 0, nameof(tolerance));
     return(Math.Abs(this.siemens - other.siemens) < tolerance.siemens);
 }
コード例 #17
0
 public bool Equals(Area other, Area tolerance)
 {
     Ensure.GreaterThan(tolerance.squareMetres, 0, nameof(tolerance));
     return(Math.Abs(this.squareMetres - other.squareMetres) < tolerance.squareMetres);
 }
コード例 #18
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Data"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Data as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Data"/> 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(Data other, Data tolerance)
 {
     Ensure.GreaterThan(tolerance.bits, 0, nameof(tolerance));
     return(Math.Abs(this.bits - other.bits) < tolerance.bits);
 }
コード例 #19
0
ファイル: Speed.generated.cs プロジェクト: forki/Gu.Units
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Speed"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Speed as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Speed"/> 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(Speed other, Speed tolerance)
 {
     Ensure.GreaterThan(tolerance.metresPerSecond, 0, nameof(tolerance));
     return(Math.Abs(this.metresPerSecond - other.metresPerSecond) < tolerance.metresPerSecond);
 }
コード例 #20
0
ファイル: Torque.generated.cs プロジェクト: forki/Gu.Units
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Torque"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Torque as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Torque"/> 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(Torque other, Torque tolerance)
 {
     Ensure.GreaterThan(tolerance.newtonMetres, 0, nameof(tolerance));
     return(Math.Abs(this.newtonMetres - other.newtonMetres) < tolerance.newtonMetres);
 }
コード例 #21
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);
 }
コード例 #22
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Pressure"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Pressure as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Pressure"/> 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(Pressure other, Pressure tolerance)
 {
     Ensure.GreaterThan(tolerance.pascals, 0, nameof(tolerance));
     return(Math.Abs(this.pascals - other.pascals) < tolerance.pascals);
 }
コード例 #23
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Density"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Density as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Density"/> 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(Density other, Density tolerance)
 {
     Ensure.GreaterThan(tolerance.kilogramsPerCubicMetre, 0, nameof(tolerance));
     return(Math.Abs(this.kilogramsPerCubicMetre - other.kilogramsPerCubicMetre) < tolerance.kilogramsPerCubicMetre);
 }
コード例 #24
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.AngularSpeed"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same AngularSpeed as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.AngularSpeed"/> 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(AngularSpeed other, AngularSpeed tolerance)
 {
     Ensure.GreaterThan(tolerance.radiansPerSecond, 0, nameof(tolerance));
     return(Math.Abs(this.radiansPerSecond - other.radiansPerSecond) < tolerance.radiansPerSecond);
 }
コード例 #25
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.KinematicViscosity"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same KinematicViscosity as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.KinematicViscosity"/> 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(KinematicViscosity other, KinematicViscosity tolerance)
 {
     Ensure.GreaterThan(tolerance.squareMetresPerSecond, 0, nameof(tolerance));
     return(Math.Abs(this.squareMetresPerSecond - other.squareMetresPerSecond) < tolerance.squareMetresPerSecond);
 }
コード例 #26
0
 public bool Equals(Current other, Current tolerance)
 {
     Ensure.GreaterThan(tolerance.amperes, 0, nameof(tolerance));
     return(Math.Abs(this.amperes - other.amperes) < tolerance.amperes);
 }
コード例 #27
0
ファイル: Mass.generated.cs プロジェクト: forki/Gu.Units
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Mass"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Mass as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Mass"/> 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(Mass other, Mass tolerance)
 {
     Ensure.GreaterThan(tolerance.kilograms, 0, nameof(tolerance));
     return(Math.Abs(this.kilograms - other.kilograms) < tolerance.kilograms);
 }
コード例 #28
0
 public bool Equals(Frequency other, Frequency tolerance)
 {
     Ensure.GreaterThan(tolerance.hertz, 0, nameof(tolerance));
     return(Math.Abs(this.hertz - other.hertz) < tolerance.hertz);
 }
コード例 #29
0
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.CatalyticActivity"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same CatalyticActivity as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.CatalyticActivity"/> 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(CatalyticActivity other, CatalyticActivity tolerance)
 {
     Ensure.GreaterThan(tolerance.katals, 0, nameof(tolerance));
     return(Math.Abs(this.katals - other.katals) < tolerance.katals);
 }
コード例 #30
0
ファイル: Angle.generated.cs プロジェクト: forki/Gu.Units
 /// <summary>
 /// Returns a quantity indicating whether this instance is equal to a specified <see cref="Gu.Units.Angle"/> object within the given tolerance.
 /// </summary>
 /// <returns>
 /// true if <paramref name="other"/> represents the same Angle as this instance; otherwise, false.
 /// </returns>
 /// <param name="other">An instance of <see cref="Gu.Units.Angle"/> 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(Angle other, Angle tolerance)
 {
     Ensure.GreaterThan(tolerance.radians, 0, nameof(tolerance));
     return(Math.Abs(this.radians - other.radians) < tolerance.radians);
 }