|
21 | 21 |
|
22 | 22 | #if !WINDOWS_UWP
|
23 | 23 | // Operator overloads not supported in Universal Windows Platform (WinRT Components)
|
24 |
| -using System; |
| 24 | +using UnitsNet.Units; |
25 | 25 |
|
26 | 26 | namespace UnitsNet
|
27 | 27 | {
|
28 | 28 | public partial struct Temperature
|
29 | 29 | {
|
| 30 | + /// <summary> |
| 31 | + /// Add a <see cref="Temperature" /> and a <see cref="TemperatureDelta" />. |
| 32 | + /// </summary> |
| 33 | + /// <remarks>Due to temperature units having different scales, the arithmetic must be performed on the same scale.</remarks> |
| 34 | + /// <returns>The new temperature.</returns> |
30 | 35 | public static Temperature operator +(Temperature left, TemperatureDelta right)
|
31 | 36 | {
|
32 | 37 | return new Temperature(left.Kelvins + right.KelvinsDelta);
|
33 | 38 | }
|
34 | 39 |
|
| 40 | + /// <summary> |
| 41 | + /// Add a <see cref="TemperatureDelta" /> and a <see cref="Temperature" />. |
| 42 | + /// </summary> |
| 43 | + /// <remarks>Due to temperature units having different scales, the arithmetic must be performed on the same scale.</remarks> |
| 44 | + /// <returns>The new temperature.</returns> |
35 | 45 | public static Temperature operator +(TemperatureDelta left, Temperature right)
|
36 | 46 | {
|
37 | 47 | return new Temperature(left.KelvinsDelta + right.Kelvins);
|
38 | 48 | }
|
39 | 49 |
|
| 50 | + /// <summary> |
| 51 | + /// Subtract a <see cref="Temperature" /> by a <see cref="TemperatureDelta" />. |
| 52 | + /// </summary> |
| 53 | + /// <remarks>Due to temperature units having different scales, the arithmetic must be performed on the same scale.</remarks> |
| 54 | + /// <returns>The new temperature.</returns> |
40 | 55 | public static Temperature operator -(Temperature left, TemperatureDelta right)
|
41 | 56 | {
|
42 | 57 | return new Temperature(left.Kelvins - right.KelvinsDelta);
|
43 | 58 | }
|
44 | 59 |
|
| 60 | + /// <summary> |
| 61 | + /// Subtract a <see cref="Temperature" /> by a <see cref="TemperatureDelta" />. |
| 62 | + /// </summary> |
| 63 | + /// <remarks>Due to temperature units having different scales, the arithmetic must be performed on the same scale.</remarks> |
| 64 | + /// <returns>The delta temperature (difference).</returns> |
45 | 65 | public static TemperatureDelta operator -(Temperature left, Temperature right)
|
46 | 66 | {
|
47 | 67 | return new TemperatureDelta(left.Kelvins - right.Kelvins);
|
48 | 68 | }
|
49 | 69 |
|
50 |
| -// public static Temperature operator *(double left, Temperature right) |
51 |
| -// { |
52 |
| -// return new Temperature(left * right.Kelvins); |
53 |
| -// } |
54 |
| -// |
55 |
| -// public static Temperature operator *(Temperature left, double right) |
56 |
| -// { |
57 |
| -// return new Temperature(left.Kelvins * right); |
58 |
| -// } |
59 |
| -// |
60 |
| -// public static Temperature operator /(Temperature left, double right) |
61 |
| -// { |
62 |
| -// return new Temperature(left.Kelvins / right); |
63 |
| -// } |
64 |
| -// |
65 |
| -// public static double operator /(Temperature left, Temperature right) |
66 |
| -// { |
67 |
| -// return Convert.ToDouble(left.Kelvins / right.Kelvins); |
68 |
| -// } |
| 70 | + /// <summary> |
| 71 | + /// Multiply temperature with a <paramref name="factor" /> in a given <paramref name="unit" />. |
| 72 | + /// </summary> |
| 73 | + /// <remarks> |
| 74 | + /// Due to different temperature units having different zero points, we cannot simply |
| 75 | + /// multiply or divide a temperature by a factor. We must first convert to the desired unit, then perform the |
| 76 | + /// calculation. |
| 77 | + /// </remarks> |
| 78 | + /// <param name="factor">Factor to multiply by.</param> |
| 79 | + /// <param name="unit">Unit to perform multiplication in.</param> |
| 80 | + /// <returns>The resulting <see cref="Temperature" />.</returns> |
| 81 | + public Temperature Multiply(double factor, TemperatureUnit unit) |
| 82 | + { |
| 83 | + double resultInUnit = As(unit) * factor; |
| 84 | + return From(resultInUnit, unit); |
| 85 | + } |
| 86 | + |
| 87 | + |
| 88 | + /// <summary> |
| 89 | + /// Divide temperature by a <paramref name="divisor" /> in a given <paramref name="unit" />. |
| 90 | + /// </summary> |
| 91 | + /// <remarks> |
| 92 | + /// Due to different temperature units having different zero points, we cannot simply |
| 93 | + /// multiply or divide a temperature by a factor. We must first convert to the desired unit, then perform the |
| 94 | + /// calculation. |
| 95 | + /// </remarks> |
| 96 | + /// <param name="divisor">Factor to multiply by.</param> |
| 97 | + /// <param name="unit">Unit to perform multiplication in.</param> |
| 98 | + /// <returns>The resulting <see cref="Temperature" />.</returns> |
| 99 | + public Temperature Divide(double divisor, TemperatureUnit unit) |
| 100 | + { |
| 101 | + double resultInUnit = As(unit) / divisor; |
| 102 | + return From(resultInUnit, unit); |
| 103 | + } |
69 | 104 | }
|
70 | 105 | }
|
71 | 106 |
|
|
0 commit comments