diff --git a/Pilz/AssemblyAppVersion.cs b/Pilz/AssemblyAppVersion.cs new file mode 100644 index 0000000..19fccf0 --- /dev/null +++ b/Pilz/AssemblyAppVersion.cs @@ -0,0 +1,17 @@ +using System.Reflection; + +namespace Pilz; + +[AttributeUsage(AttributeTargets.Assembly)] +public class AssemblyAppVersionAttribute(string version, int build, AppChannel channel) : Attribute +{ + public AppVersion Version { get; } = new(new Version(version), build, channel); + + public AssemblyAppVersionAttribute(string version) : this(version, 1) + { + } + + public AssemblyAppVersionAttribute(string version, int build) : this(version, build, AppChannel.Stable) + { + } +} \ No newline at end of file diff --git a/Pilz/Extensions/AssemblyExtensions.cs b/Pilz/Extensions/AssemblyExtensions.cs new file mode 100644 index 0000000..cd0adb5 --- /dev/null +++ b/Pilz/Extensions/AssemblyExtensions.cs @@ -0,0 +1,11 @@ +using System.Reflection; + +namespace Pilz.Extensions; + +public static class AssemblyExtensions +{ + public static AppVersion GetAppVersion(this Assembly @this) + { + return @this.GetCustomAttribute()?.Version ?? new(); + } +}