Skip to content

Commit 6ef823f

Browse files
committed
added static acess variables for all UnitSystems
in order to avoid breaking the namespace (UnitSystem.SI) all static instances were added to the UnitSystem.Definition (partial class)
1 parent b844f26 commit 6ef823f

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

UnitsNet/UnitSystem.Definitions.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Licensed under MIT No Attribution, see LICENSE file at the root.
2+
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet.
3+
4+
using UnitsNet.UnitSystems;
5+
6+
namespace UnitsNet
7+
{
8+
public partial class UnitSystem
9+
{
10+
/// <summary>
11+
/// Gets the SI unit system.
12+
/// </summary>
13+
public static SI SI { get; } = new SI();
14+
15+
16+
/// <summary>
17+
/// Gets the British Imperial unit system.
18+
/// </summary>
19+
public static BI BI { get; } = new BI();
20+
21+
22+
/// <summary>
23+
/// Gets the English Engineering unit system.
24+
/// </summary>
25+
public static EE EE { get; } = new EE();
26+
27+
28+
/// <summary>
29+
/// Gets the United States Customary unit system.
30+
/// </summary>
31+
public static USC USC { get; } = new USC();
32+
33+
34+
/// <summary>
35+
/// Gets the Centimeter–Gram–Second unit system.
36+
/// </summary>
37+
public static CGS CGS { get; } = new CGS();
38+
39+
40+
/// <summary>
41+
/// Gets the Foot–Pound–Second unit system.
42+
/// </summary>
43+
public static FPS FPS { get; } = new FPS();
44+
45+
46+
/// <summary>
47+
/// Gets the unit system of typical astronomical units
48+
/// </summary>
49+
public static Astronomical Astronomical { get; } = new Astronomical();
50+
51+
}
52+
}

UnitsNet/UnitSystem.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace UnitsNet
1313
/// selected base units,
1414
/// such as <see cref="SI" /> to use SI base units such as meters, kilograms and seconds.
1515
/// </summary>
16-
public class UnitSystem : IEquatable<UnitSystem>
16+
public partial class UnitSystem : IEquatable<UnitSystem>
1717
{
1818
// the array used for storing the default units in the current UnitSystem, ordered by QuantityType (excluding QuantityType.Undefined)
1919
private readonly Lazy<UnitSystemInfo[]> _systemUnits;
@@ -70,11 +70,6 @@ protected UnitSystem(Lazy<UnitSystemInfo[]> systemUnits)
7070
_systemUnits = systemUnits;
7171
}
7272

73-
/// <summary>
74-
/// Gets the SI unit system.
75-
/// </summary>
76-
public static SI SI { get; } = new SI();
77-
7873
/// <summary>
7974
/// Gets the default unit information for the given quantity type, associated with the current unit system.
8075
/// For example: the default unit of length in SI is the 'meter' abbreviated with the letter 'm'.

0 commit comments

Comments
 (0)