|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
namespace Console.Waterworks.Specialists
|
|
|
|
{
|
|
|
|
class ProgramInfoSpecialist
|
|
|
|
{
|
|
|
|
internal List<string> GatherProgramInfomation()
|
|
|
|
{
|
|
|
|
var info = new List<string>()
|
|
|
|
{
|
|
|
|
addProductLine(),
|
|
|
|
addCompanyLine(),
|
|
|
|
addCopyRightLine(),
|
|
|
|
addProductDescription()
|
|
|
|
};
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
private string addCopyRightLine()
|
|
|
|
{
|
|
|
|
Assembly assembly = Assembly.GetEntryAssembly();
|
|
|
|
var copyRightAttribute = assembly
|
|
|
|
.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)
|
|
|
|
.OfType<AssemblyCopyrightAttribute>()
|
|
|
|
.FirstOrDefault();
|
|
|
|
return (copyRightAttribute != null) ? copyRightAttribute.Copyright : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
string addProductLine()
|
|
|
|
{
|
|
|
|
var name = GetProductName();
|
|
|
|
var buildInfo = getBuildInfo();
|
|
|
|
return (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(buildInfo)) ? $"{name} {buildInfo}" : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
string addCompanyLine()
|
|
|
|
{
|
|
|
|
Assembly assembly = Assembly.GetEntryAssembly();
|
|
|
|
var companyAttribute = assembly
|
|
|
|
.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)
|
|
|
|
.OfType<AssemblyCompanyAttribute>()
|
|
|
|
.FirstOrDefault();
|
|
|
|
return (companyAttribute != null) ? companyAttribute.Company : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
string addProductDescription()
|
|
|
|
{
|
|
|
|
Assembly assembly = Assembly.GetEntryAssembly();
|
|
|
|
var descriptionAttribute = assembly
|
|
|
|
.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)
|
|
|
|
.OfType<AssemblyDescriptionAttribute>()
|
|
|
|
.FirstOrDefault();
|
|
|
|
return (descriptionAttribute != null) ? descriptionAttribute.Description : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal string GetProductName()
|
|
|
|
{
|
|
|
|
Assembly assembly = Assembly.GetEntryAssembly();
|
|
|
|
var productAttribute = assembly
|
|
|
|
.GetCustomAttributes(typeof(AssemblyProductAttribute), false)
|
|
|
|
.OfType<AssemblyProductAttribute>()
|
|
|
|
.FirstOrDefault();
|
|
|
|
return (productAttribute != null) ? productAttribute.Product : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
string getBuildInfo() => Assembly.GetEntryAssembly().GetName().Version.ToString();
|
|
|
|
}
|
|
|
|
}
|