Console.Waterworks.Core is the .Net Core version of Console.Waterworks.
https://www.craigoates.net/Software/project/8
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.9 KiB
59 lines
1.9 KiB
7 years ago
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Reflection;
|
||
|
|
||
|
namespace Console.Waterworks.Core.Specialists
|
||
|
{
|
||
|
class ProgramInfoSpecialist
|
||
|
{
|
||
|
internal List<string> GatherProgramInfomation()
|
||
|
{
|
||
|
var info = new List<string>()
|
||
|
{
|
||
|
addProductLine(),
|
||
|
addCompanyLine(),
|
||
|
addCopyRightLine(),
|
||
|
addProductDescription()
|
||
|
};
|
||
|
return info;
|
||
|
}
|
||
|
|
||
|
private string addCopyRightLine()
|
||
|
{
|
||
|
var assembly = Assembly.GetEntryAssembly();
|
||
|
var copyRightAttribute = assembly.GetCustomAttributes<AssemblyCopyrightAttribute>().FirstOrDefault();
|
||
|
return copyRightAttribute?.Copyright;
|
||
|
}
|
||
|
|
||
|
string addProductLine()
|
||
|
{
|
||
|
var name = GetProductName();
|
||
|
var buildInfo = getBuildInfo();
|
||
|
return (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(buildInfo)) ? $"{name} {buildInfo}" : null;
|
||
|
}
|
||
|
|
||
|
string addCompanyLine()
|
||
|
{
|
||
|
var assembly = Assembly.GetEntryAssembly();
|
||
|
var companyAttribute = assembly.GetCustomAttributes<AssemblyCompanyAttribute>().FirstOrDefault();
|
||
|
return companyAttribute?.Company;
|
||
|
}
|
||
|
|
||
|
string addProductDescription()
|
||
|
{
|
||
|
var assembly = Assembly.GetEntryAssembly();
|
||
|
var descriptionAttribute = assembly.GetCustomAttributes<AssemblyDescriptionAttribute>().FirstOrDefault();
|
||
|
return descriptionAttribute?.Description;
|
||
|
}
|
||
|
|
||
|
internal string GetProductName()
|
||
|
{
|
||
|
var assembly = Assembly.GetEntryAssembly();
|
||
|
var productAttribute = assembly.GetCustomAttributes<AssemblyProductAttribute>().FirstOrDefault();
|
||
|
return productAttribute?.Product;
|
||
|
}
|
||
|
|
||
|
string getBuildInfo() => Assembly.GetEntryAssembly().GetName().Version.ToString();
|
||
|
}
|
||
|
}
|