|
1 |
| -using System.Runtime.InteropServices; |
| 1 | +using System.IO; |
| 2 | +using System.Reflection; |
| 3 | +using System.Runtime.InteropServices; |
2 | 4 |
|
3 | 5 | [assembly: ComVisible(false)]
|
4 | 6 | [assembly: Guid("ab848ecd-76aa-41c0-b63d-86a8591b25aa")]
|
| 7 | + |
| 8 | +namespace WindowsDesktop.Properties; |
| 9 | + |
| 10 | +internal static class AssemblyInfo |
| 11 | +{ |
| 12 | + private static readonly Assembly _assembly = Assembly.GetExecutingAssembly(); |
| 13 | + private static string? _title; |
| 14 | + private static string? _description; |
| 15 | + private static string? _company; |
| 16 | + private static string? _product; |
| 17 | + private static string? _copyright; |
| 18 | + private static string? _trademark; |
| 19 | + private static string? _versionString; |
| 20 | + |
| 21 | + public static string Title |
| 22 | + => _title ??= Prop<AssemblyTitleAttribute>(x => x.Title); |
| 23 | + |
| 24 | + public static string Description |
| 25 | + => _description ??= Prop<AssemblyDescriptionAttribute>(x => x.Description); |
| 26 | + |
| 27 | + public static string Company |
| 28 | + => _company ??= Prop<AssemblyCompanyAttribute>(x => x.Company); |
| 29 | + |
| 30 | + public static string Product |
| 31 | + => _product ??= Prop<AssemblyProductAttribute>(x => x.Product); |
| 32 | + |
| 33 | + public static string Copyright |
| 34 | + => _copyright ??= Prop<AssemblyCopyrightAttribute>(x => x.Copyright); |
| 35 | + |
| 36 | + public static string Trademark |
| 37 | + => _trademark ??= Prop<AssemblyTrademarkAttribute>(x => x.Trademark); |
| 38 | + |
| 39 | + public static Version Version |
| 40 | + => _assembly.GetName().Version ?? new Version(); |
| 41 | + |
| 42 | + public static string VersionString |
| 43 | + => _versionString ??= Version.ToString(3); |
| 44 | + |
| 45 | + private static string Prop<T>(Func<T, string> propSelector) |
| 46 | + where T : Attribute |
| 47 | + { |
| 48 | + var attribute = _assembly.GetCustomAttribute<T>(); |
| 49 | + return attribute != null ? propSelector(attribute) : ""; |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +internal static class LocationInfo |
| 54 | +{ |
| 55 | + private static DirectoryInfo? _localAppData; |
| 56 | + |
| 57 | + internal static DirectoryInfo LocalAppData |
| 58 | + => _localAppData ??= new DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AssemblyInfo.Company, AssemblyInfo.Product)); |
| 59 | +} |
0 commit comments