23
23
24
24
namespace UnitsNet
25
25
{
26
- /// <summary>
27
- /// Extension methods for <see cref="AmplitudeRatio" />.
28
- /// </summary>
29
- public static class AmplitudeRatioExtensions
30
- {
31
- /// <summary>
32
- /// Gets an <see cref="ElectricPotential" /> from <see cref="AmplitudeRatio" />.
33
- /// </summary>
34
- /// <paramref name="amplitudeRatio">The amplitude ratio to convert.</paramref>
35
- /// <remarks>
36
- /// Provides a nicer syntax for converting an amplitude ratio back to a voltage.
37
- /// <example>
38
- /// <c>var voltage = voltageRatio.ToElectricPotential();</c>
39
- /// </example>
40
- /// </remarks>
41
- public static ElectricPotential ToElectricPotential ( this AmplitudeRatio amplitudeRatio )
42
- {
43
- return AmplitudeRatio . ToElectricPotential ( amplitudeRatio ) ;
44
- }
45
-
46
- /// <summary>
47
- /// Converts a <see cref="AmplitudeRatio" /> to a <see cref="PowerRatio" />.
48
- /// </summary>
49
- /// <param name="amplitudeRatio">The amplitude ratio to convert.</param>
50
- /// <param name="impedance">The input impedance of the load. This is usually 50, 75 or 600 ohms.</param>
51
- /// <remarks>http://www.maximintegrated.com/en/app-notes/index.mvp/id/808</remarks>
52
- public static PowerRatio ToPowerRatio ( this AmplitudeRatio amplitudeRatio , ElectricResistance impedance )
53
- {
54
- return AmplitudeRatio . ToPowerRatio ( amplitudeRatio , impedance ) ;
55
- }
56
- }
57
-
58
- /// <summary>
59
- /// Extension methods for <see cref="ElectricPotential" />.
60
- /// </summary>
61
- public static class ElectricPotentialExtensions
62
- {
63
- /// <summary>
64
- /// Gets an <see cref="AmplitudeRatio" /> in decibels (dB) relative to 1 volt RMS from an
65
- /// <see cref="ElectricPotential" />.
66
- /// </summary>
67
- /// <remarks>
68
- /// Provides a nicer syntax for converting a voltage to an amplitude ratio (relative to 1 volt RMS).
69
- /// <example>
70
- /// <c>var voltageRatio = voltage.ToAmplitudeRatio();</c>
71
- /// </example>
72
- /// </remarks>
73
- public static AmplitudeRatio ToAmplitudeRatio ( this ElectricPotential voltage )
74
- {
75
- return AmplitudeRatio . FromElectricPotential ( voltage ) ;
76
- }
77
- }
78
-
26
+ #if WINDOWS_UWP
27
+ public sealed partial class AmplitudeRatio
28
+ #else
79
29
public partial struct AmplitudeRatio
30
+ #endif
80
31
{
81
32
/// <summary>
82
33
/// Initializes a new instance of the <see cref="AmplitudeRatio" /> struct from the specified electric potential
@@ -85,7 +36,13 @@ public partial struct AmplitudeRatio
85
36
/// resistance.
86
37
/// </summary>
87
38
/// <param name="voltage">The electric potential referenced to one volt.</param>
88
- public AmplitudeRatio ( ElectricPotential voltage )
39
+ // Operator overloads not supported in Universal Windows Platform (WinRT Components)
40
+ #if WINDOWS_UWP
41
+ internal
42
+ #else
43
+ public
44
+ #endif
45
+ AmplitudeRatio ( ElectricPotential voltage )
89
46
: this ( )
90
47
{
91
48
if ( voltage . Volts <= 0 )
@@ -94,7 +51,7 @@ public AmplitudeRatio(ElectricPotential voltage)
94
51
"The base-10 logarithm of a number ≤ 0 is undefined. Voltage must be greater than 0 V." ) ;
95
52
96
53
// E(dBV) = 20*log10(value(V)/reference(V))
97
- _decibelVolts = 20 * Math . Log10 ( voltage / ElectricPotential . FromVolts ( 1 ) ) ;
54
+ _decibelVolts = 20 * Math . Log10 ( voltage . Volts / 1 ) ;
98
55
}
99
56
100
57
/// <summary>
0 commit comments