Skip to content

Commit 50c0f30

Browse files
authored
Adding IQuantity interface. Currently only has the QuantityType and BaseDimensions properties. (#462)
1 parent e80240b commit 50c0f30

File tree

92 files changed

+1355
-433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1355
-433
lines changed

Common/GeneratedCode/Quantities/Acceleration.Common.g.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ namespace UnitsNet
5757
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
5858
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
5959
#if WINDOWS_UWP
60-
public sealed partial class Acceleration
60+
public sealed partial class Acceleration : IQuantity
6161
#else
62-
public partial struct Acceleration : IComparable, IComparable<Acceleration>
62+
public partial struct Acceleration : IQuantity, IComparable, IComparable<Acceleration>
6363
#endif
6464
{
6565
/// <summary>
@@ -77,6 +77,11 @@ public partial struct Acceleration : IComparable, IComparable<Acceleration>
7777
/// </summary>
7878
public AccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit);
7979

80+
static Acceleration()
81+
{
82+
BaseDimensions = new BaseDimensions(1, 0, -2, 0, 0, 0, 0);
83+
}
84+
8085
[Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
8186
public Acceleration(double meterspersecondsquared)
8287
{
@@ -140,14 +145,12 @@ public Acceleration(double meterspersecondsquared)
140145
/// </summary>
141146
public static AccelerationUnit BaseUnit => AccelerationUnit.MeterPerSecondSquared;
142147

143-
private static readonly BaseDimensions _baseDimensions = new BaseDimensions(1, 0, -2, 0, 0, 0, 0);
144-
145148
/// <summary>
146149
/// The <see cref="BaseDimensions" /> of this quantity.
147150
/// </summary>
148151
public static BaseDimensions BaseDimensions
149152
{
150-
get{ return _baseDimensions; }
153+
get;
151154
}
152155

153156
/// <summary>
@@ -983,6 +986,11 @@ public string ToString(
983986
/// </summary>
984987
public static Acceleration MinValue => new Acceleration(double.MinValue, BaseUnit);
985988

989+
/// <summary>
990+
/// The <see cref="QuantityType" /> of this quantity.
991+
/// </summary>
992+
public QuantityType Type => Acceleration.QuantityType;
993+
986994
/// <summary>
987995
/// The <see cref="BaseDimensions" /> of this quantity.
988996
/// </summary>

Common/GeneratedCode/Quantities/AmountOfSubstance.Common.g.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ namespace UnitsNet
5757
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
5858
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
5959
#if WINDOWS_UWP
60-
public sealed partial class AmountOfSubstance
60+
public sealed partial class AmountOfSubstance : IQuantity
6161
#else
62-
public partial struct AmountOfSubstance : IComparable, IComparable<AmountOfSubstance>
62+
public partial struct AmountOfSubstance : IQuantity, IComparable, IComparable<AmountOfSubstance>
6363
#endif
6464
{
6565
/// <summary>
@@ -77,6 +77,11 @@ public partial struct AmountOfSubstance : IComparable, IComparable<AmountOfSubst
7777
/// </summary>
7878
public AmountOfSubstanceUnit Unit => _unit.GetValueOrDefault(BaseUnit);
7979

80+
static AmountOfSubstance()
81+
{
82+
BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 1, 0);
83+
}
84+
8085
[Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
8186
public AmountOfSubstance(double moles)
8287
{
@@ -140,14 +145,12 @@ public AmountOfSubstance(double moles)
140145
/// </summary>
141146
public static AmountOfSubstanceUnit BaseUnit => AmountOfSubstanceUnit.Mole;
142147

143-
private static readonly BaseDimensions _baseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 1, 0);
144-
145148
/// <summary>
146149
/// The <see cref="BaseDimensions" /> of this quantity.
147150
/// </summary>
148151
public static BaseDimensions BaseDimensions
149152
{
150-
get{ return _baseDimensions; }
153+
get;
151154
}
152155

153156
/// <summary>
@@ -1003,6 +1006,11 @@ public string ToString(
10031006
/// </summary>
10041007
public static AmountOfSubstance MinValue => new AmountOfSubstance(double.MinValue, BaseUnit);
10051008

1009+
/// <summary>
1010+
/// The <see cref="QuantityType" /> of this quantity.
1011+
/// </summary>
1012+
public QuantityType Type => AmountOfSubstance.QuantityType;
1013+
10061014
/// <summary>
10071015
/// The <see cref="BaseDimensions" /> of this quantity.
10081016
/// </summary>

Common/GeneratedCode/Quantities/AmplitudeRatio.Common.g.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ namespace UnitsNet
5757
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
5858
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
5959
#if WINDOWS_UWP
60-
public sealed partial class AmplitudeRatio
60+
public sealed partial class AmplitudeRatio : IQuantity
6161
#else
62-
public partial struct AmplitudeRatio : IComparable, IComparable<AmplitudeRatio>
62+
public partial struct AmplitudeRatio : IQuantity, IComparable, IComparable<AmplitudeRatio>
6363
#endif
6464
{
6565
/// <summary>
@@ -77,6 +77,10 @@ public partial struct AmplitudeRatio : IComparable, IComparable<AmplitudeRatio>
7777
/// </summary>
7878
public AmplitudeRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit);
7979

80+
static AmplitudeRatio()
81+
{
82+
}
83+
8084
[Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
8185
public AmplitudeRatio(double decibelvolts)
8286
{
@@ -140,6 +144,14 @@ public AmplitudeRatio(double decibelvolts)
140144
/// </summary>
141145
public static AmplitudeRatioUnit BaseUnit => AmplitudeRatioUnit.DecibelVolt;
142146

147+
/// <summary>
148+
/// The <see cref="BaseDimensions" /> of this quantity.
149+
/// </summary>
150+
public static BaseDimensions BaseDimensions
151+
{
152+
get;
153+
}
154+
143155
/// <summary>
144156
/// All units of measurement for the AmplitudeRatio quantity.
145157
/// </summary>
@@ -793,5 +805,14 @@ public string ToString(
793805
/// </summary>
794806
public static AmplitudeRatio MinValue => new AmplitudeRatio(double.MinValue, BaseUnit);
795807

808+
/// <summary>
809+
/// The <see cref="QuantityType" /> of this quantity.
810+
/// </summary>
811+
public QuantityType Type => AmplitudeRatio.QuantityType;
812+
813+
/// <summary>
814+
/// The <see cref="BaseDimensions" /> of this quantity.
815+
/// </summary>
816+
public BaseDimensions Dimensions => AmplitudeRatio.BaseDimensions;
796817
}
797818
}

Common/GeneratedCode/Quantities/Angle.Common.g.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ namespace UnitsNet
5757
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
5858
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
5959
#if WINDOWS_UWP
60-
public sealed partial class Angle
60+
public sealed partial class Angle : IQuantity
6161
#else
62-
public partial struct Angle : IComparable, IComparable<Angle>
62+
public partial struct Angle : IQuantity, IComparable, IComparable<Angle>
6363
#endif
6464
{
6565
/// <summary>
@@ -77,6 +77,10 @@ public partial struct Angle : IComparable, IComparable<Angle>
7777
/// </summary>
7878
public AngleUnit Unit => _unit.GetValueOrDefault(BaseUnit);
7979

80+
static Angle()
81+
{
82+
}
83+
8084
[Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
8185
public Angle(double degrees)
8286
{
@@ -140,6 +144,14 @@ public Angle(double degrees)
140144
/// </summary>
141145
public static AngleUnit BaseUnit => AngleUnit.Degree;
142146

147+
/// <summary>
148+
/// The <see cref="BaseDimensions" /> of this quantity.
149+
/// </summary>
150+
public static BaseDimensions BaseDimensions
151+
{
152+
get;
153+
}
154+
143155
/// <summary>
144156
/// All units of measurement for the Angle quantity.
145157
/// </summary>
@@ -993,5 +1005,14 @@ public string ToString(
9931005
/// </summary>
9941006
public static Angle MinValue => new Angle(double.MinValue, BaseUnit);
9951007

1008+
/// <summary>
1009+
/// The <see cref="QuantityType" /> of this quantity.
1010+
/// </summary>
1011+
public QuantityType Type => Angle.QuantityType;
1012+
1013+
/// <summary>
1014+
/// The <see cref="BaseDimensions" /> of this quantity.
1015+
/// </summary>
1016+
public BaseDimensions Dimensions => Angle.BaseDimensions;
9961017
}
9971018
}

Common/GeneratedCode/Quantities/ApparentEnergy.Common.g.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ namespace UnitsNet
5757
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
5858
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
5959
#if WINDOWS_UWP
60-
public sealed partial class ApparentEnergy
60+
public sealed partial class ApparentEnergy : IQuantity
6161
#else
62-
public partial struct ApparentEnergy : IComparable, IComparable<ApparentEnergy>
62+
public partial struct ApparentEnergy : IQuantity, IComparable, IComparable<ApparentEnergy>
6363
#endif
6464
{
6565
/// <summary>
@@ -77,6 +77,11 @@ public partial struct ApparentEnergy : IComparable, IComparable<ApparentEnergy>
7777
/// </summary>
7878
public ApparentEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit);
7979

80+
static ApparentEnergy()
81+
{
82+
BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0);
83+
}
84+
8085
[Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
8186
public ApparentEnergy(double voltamperehours)
8287
{
@@ -140,14 +145,12 @@ public ApparentEnergy(double voltamperehours)
140145
/// </summary>
141146
public static ApparentEnergyUnit BaseUnit => ApparentEnergyUnit.VoltampereHour;
142147

143-
private static readonly BaseDimensions _baseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0);
144-
145148
/// <summary>
146149
/// The <see cref="BaseDimensions" /> of this quantity.
147150
/// </summary>
148151
public static BaseDimensions BaseDimensions
149152
{
150-
get{ return _baseDimensions; }
153+
get;
151154
}
152155

153156
/// <summary>
@@ -783,6 +786,11 @@ public string ToString(
783786
/// </summary>
784787
public static ApparentEnergy MinValue => new ApparentEnergy(double.MinValue, BaseUnit);
785788

789+
/// <summary>
790+
/// The <see cref="QuantityType" /> of this quantity.
791+
/// </summary>
792+
public QuantityType Type => ApparentEnergy.QuantityType;
793+
786794
/// <summary>
787795
/// The <see cref="BaseDimensions" /> of this quantity.
788796
/// </summary>

Common/GeneratedCode/Quantities/ApparentPower.Common.g.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ namespace UnitsNet
5757
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
5858
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
5959
#if WINDOWS_UWP
60-
public sealed partial class ApparentPower
60+
public sealed partial class ApparentPower : IQuantity
6161
#else
62-
public partial struct ApparentPower : IComparable, IComparable<ApparentPower>
62+
public partial struct ApparentPower : IQuantity, IComparable, IComparable<ApparentPower>
6363
#endif
6464
{
6565
/// <summary>
@@ -77,6 +77,11 @@ public partial struct ApparentPower : IComparable, IComparable<ApparentPower>
7777
/// </summary>
7878
public ApparentPowerUnit Unit => _unit.GetValueOrDefault(BaseUnit);
7979

80+
static ApparentPower()
81+
{
82+
BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0);
83+
}
84+
8085
[Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
8186
public ApparentPower(double voltamperes)
8287
{
@@ -140,14 +145,12 @@ public ApparentPower(double voltamperes)
140145
/// </summary>
141146
public static ApparentPowerUnit BaseUnit => ApparentPowerUnit.Voltampere;
142147

143-
private static readonly BaseDimensions _baseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0);
144-
145148
/// <summary>
146149
/// The <see cref="BaseDimensions" /> of this quantity.
147150
/// </summary>
148151
public static BaseDimensions BaseDimensions
149152
{
150-
get{ return _baseDimensions; }
153+
get;
151154
}
152155

153156
/// <summary>
@@ -803,6 +806,11 @@ public string ToString(
803806
/// </summary>
804807
public static ApparentPower MinValue => new ApparentPower(double.MinValue, BaseUnit);
805808

809+
/// <summary>
810+
/// The <see cref="QuantityType" /> of this quantity.
811+
/// </summary>
812+
public QuantityType Type => ApparentPower.QuantityType;
813+
806814
/// <summary>
807815
/// The <see cref="BaseDimensions" /> of this quantity.
808816
/// </summary>

Common/GeneratedCode/Quantities/Area.Common.g.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ namespace UnitsNet
5757
// Public structures can't have any members other than public fields, and those fields must be value types or strings.
5858
// Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic.
5959
#if WINDOWS_UWP
60-
public sealed partial class Area
60+
public sealed partial class Area : IQuantity
6161
#else
62-
public partial struct Area : IComparable, IComparable<Area>
62+
public partial struct Area : IQuantity, IComparable, IComparable<Area>
6363
#endif
6464
{
6565
/// <summary>
@@ -77,6 +77,11 @@ public partial struct Area : IComparable, IComparable<Area>
7777
/// </summary>
7878
public AreaUnit Unit => _unit.GetValueOrDefault(BaseUnit);
7979

80+
static Area()
81+
{
82+
BaseDimensions = new BaseDimensions(2, 0, 0, 0, 0, 0, 0);
83+
}
84+
8085
[Obsolete("Use the constructor that takes a unit parameter. This constructor will be removed in a future version.")]
8186
public Area(double squaremeters)
8287
{
@@ -140,14 +145,12 @@ public Area(double squaremeters)
140145
/// </summary>
141146
public static AreaUnit BaseUnit => AreaUnit.SquareMeter;
142147

143-
private static readonly BaseDimensions _baseDimensions = new BaseDimensions(2, 0, 0, 0, 0, 0, 0);
144-
145148
/// <summary>
146149
/// The <see cref="BaseDimensions" /> of this quantity.
147150
/// </summary>
148151
public static BaseDimensions BaseDimensions
149152
{
150-
get{ return _baseDimensions; }
153+
get;
151154
}
152155

153156
/// <summary>
@@ -983,6 +986,11 @@ public string ToString(
983986
/// </summary>
984987
public static Area MinValue => new Area(double.MinValue, BaseUnit);
985988

989+
/// <summary>
990+
/// The <see cref="QuantityType" /> of this quantity.
991+
/// </summary>
992+
public QuantityType Type => Area.QuantityType;
993+
986994
/// <summary>
987995
/// The <see cref="BaseDimensions" /> of this quantity.
988996
/// </summary>

0 commit comments

Comments
 (0)