-
Notifications
You must be signed in to change notification settings - Fork 407
Expand file tree
/
Copy pathStaticQuantityGenerator.cs
More file actions
48 lines (42 loc) · 1.28 KB
/
StaticQuantityGenerator.cs
File metadata and controls
48 lines (42 loc) · 1.28 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
40
41
42
43
44
45
46
47
48
using CodeGen.JsonTypes;
namespace CodeGen.Generators.UnitsNetGen
{
internal class StaticQuantityGenerator : GeneratorBase
{
private readonly Quantity[] _quantities;
public StaticQuantityGenerator(Quantity[] quantities)
{
_quantities = quantities;
}
public string Generate()
{
Writer.WL(GeneratedFileHeader);
Writer.WL(@"
#nullable enable
namespace UnitsNet;
/// <summary>
/// Dynamically parse or construct quantities when types are only known at runtime.
/// </summary>
public partial class Quantity
{
/// <summary>
/// Serves as a repository for predefined quantity conversion mappings, facilitating the automatic generation and retrieval of unit conversions in the UnitsNet library.
/// </summary>
internal static class DefaultProvider
{
/// <summary>
/// All QuantityInfo instances that are present in UnitsNet by default.
/// </summary>
internal static IReadOnlyList<QuantityInfo> Quantities { get; } =
[");
foreach (var quantity in _quantities)
Writer.WL($@"
{quantity.Name}.Info,");
Writer.WL(@"
];
}
}");
return Writer.ToString();
}
}
}