-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathVersionInfo.cs
More file actions
52 lines (47 loc) · 1.9 KB
/
VersionInfo.cs
File metadata and controls
52 lines (47 loc) · 1.9 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
49
50
51
52
using System;
using kOS.Safe.Encapsulation.Suffixes;
namespace kOS.Safe.Encapsulation
{
[kOS.Safe.Utilities.KOSNomenclature("Version")]
public class VersionInfo : Structure
{
private readonly int major;
private readonly int minor;
private readonly int patch;
private readonly int build;
public Version SystemVersion => new Version(major, minor, patch, build);
public VersionInfo(Version version)
{
// NOTICE: there is a clash of nomenclature here. C# calls the
// 3rd number "BUILD" and the 4th number "Revision" while the AVC mod
// (and presumably CKAN) calls the 3rd number "PATCH" and the 4th number "BUILD".
// We'll be using the AVC terminology in kerboscript, thus why this next line
// passes in "ver.Revision" where the VersionInfo's "BUILD" goes, and the
// "ver.Build" where VersionInfo's "PATCH" goes:
major = version.Major;
minor = version.Minor;
patch = version.Build;
build = version.Revision;
VersionInitializeSuffixes();
}
public VersionInfo(int major, int minor, int patch, int build)
{
this.major = major;
this.minor = minor;
this.patch = patch;
this.build = build;
VersionInitializeSuffixes();
}
private void VersionInitializeSuffixes()
{
AddSuffix("MAJOR", new StaticSuffix<ScalarValue>(() => major));
AddSuffix("MINOR", new StaticSuffix<ScalarValue>(() => minor));
AddSuffix("PATCH", new StaticSuffix<ScalarValue>(() => patch));
AddSuffix("BUILD", new StaticSuffix<ScalarValue>(() => build));
}
public override string ToString()
{
return string.Format("{0}.{1}.{2}.{3}", major, minor, patch, build);
}
}
}