-
Notifications
You must be signed in to change notification settings - Fork 414
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (32 loc) · 1.01 KB
/
Copy pathProgram.cs
File metadata and controls
39 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Licensed under MIT No Attribution, see LICENSE file at the root.
using UnitsNet;
using UnitsNet.Modular;
using UnitsNet.Units;
using Catalog = UnitsNet.Modular.BuiltIns;
namespace QuantitySelectionSample;
[UnitSet("regex:.*Meter$")]
internal interface MeterUnitSet
{
}
[UnitSet("regex:.*Byte$")]
internal interface ByteUnitSet
{
}
[UnitsNetModule]
internal interface SelectedUnits :
IInclude<Catalog.LengthSpec, MeterUnitSet>,
IInclude<Catalog.InformationSpec, ByteUnitSet>
{
}
internal static class Program
{
public static void Main()
{
Length parsed = Length.Parse("2.5 km");
Information payload = Information.FromKibibytes(2);
Console.WriteLine($"{parsed} = {parsed.ToUnit(LengthUnit.Meter)}");
Console.WriteLine($"{payload} = {payload.ToUnit(InformationUnit.Bit)}");
Console.WriteLine($"Generated quantities: {nameof(Length)}, {nameof(Information)}");
Console.WriteLine($"Generated length units: {string.Join(", ", Enum.GetNames<LengthUnit>())}");
}
}