35 lines
1.4 KiB
C#
35 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using Kreta.Core;
|
|
|
|
namespace Kreta.BusinessLogic.VersionInfo
|
|
{
|
|
public class VersionInfoHelper
|
|
{
|
|
/// <summary>
|
|
/// Gets the filtered assembly information.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static Dictionary<string, string> GetFilteredAssemblyInformation()
|
|
{
|
|
var result = new Dictionary<string, string>();
|
|
|
|
Assembly targetAssembly = Assembly.GetExecutingAssembly();
|
|
|
|
var targetVersion = targetAssembly.GetName().Version.ToString();
|
|
|
|
result.Add(Constants.Version.BuildVersion, targetVersion);
|
|
|
|
var targetAssemblyAttributes = targetAssembly.GetCustomAttributes().OfType<AssemblyMetadataAttribute>();
|
|
|
|
result.Add(Constants.Version.BranchName, targetAssemblyAttributes.SingleOrDefault(x => x.Key == Constants.Version.BranchName)?.Value ?? Constants.Version.NotAvailable);
|
|
|
|
result.Add(Constants.Version.BuildDateTimeUtc, targetAssemblyAttributes.SingleOrDefault(x => x.Key == Constants.Version.BuildDateTimeUtc)?.Value ?? Constants.Version.NotAvailable);
|
|
|
|
result.Add(Constants.Version.CommitNumber, targetAssemblyAttributes.SingleOrDefault(x => x.Key == Constants.Version.CommitNumber)?.Value ?? Constants.Version.NotAvailable);
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|