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.
 
 

182 lines
6.4 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
namespace ASM
{
public static class ASMBL
{
#region Методы доступа к атрибутам сборки
public static string AssemblyTitle
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
if (attributes.Length > 0)
{
AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
if (titleAttribute.Title != "")
{
return titleAttribute.Title;
}
}
return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
}
}
public static string AssemblyVersion
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
public static string AssemblyDescription
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyDescriptionAttribute)attributes[0]).Description;
}
}
public static string AssemblyProduct
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
if (attributes.Length == 0)
{
return "";
}
#if DEBUG
return ((AssemblyProductAttribute)attributes[0]).Product + " Debug version";
#else
return ((AssemblyProductAttribute)attributes[0]).Product + " Release version";
#endif
}
}
public static string AssemblyCopyright
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}
public static string AssemblyCompany
{
get
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
if (attributes.Length == 0)
{
return "";
}
return ((AssemblyCompanyAttribute)attributes[0]).Company;
}
}
public static string AssemblyConfiguration
{
get
{
#if DEBUG
return "Debug version";
#else
return "Release version";
#endif
}
}
public static string[] AssemblyConf
{
get
{
string[] s = new string[11];
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
#if DEBUG
s[0] = "Debug version";
#else
s[0] = "Release version";
#endif
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyAlgorithmIdAttribute), false);
if (attributes.Length == 0)
s[1] = "AssemblyAlgorithmId = ";
else
s[1] = "AssemblyAlgorithmId = " + ((AssemblyAlgorithmIdAttribute)attributes[0]).AlgorithmId;
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
if (attributes.Length == 0)
s[2] = "AssemblyCompany = ";
else
s[2] = "AssemblyCompany = " + ((AssemblyCompanyAttribute)attributes[0]).Company;
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
if (attributes.Length == 0)
s[3] = "AssemblyCopyright = ";
else
s[3] = "AssemblyCopyright = " + ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
if (attributes.Length == 0)
s[4] = "AssemblyDescription = ";
else
s[4] = "AssemblyDescription = " + ((AssemblyDescriptionAttribute)attributes[0]).Description;
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
if (attributes.Length == 0)
s[5] = "AssemblyFileVersion = ";
else
s[5] = "AssemblyFileVersion = " + ((AssemblyFileVersionAttribute)attributes[0]).Version;
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
if (attributes.Length == 0)
s[6] = "AssemblyInformationalVersion = ";
else
s[6] = "AssemblyInformationalVersion = " + ((AssemblyInformationalVersionAttribute)attributes[0]).InformationalVersion;
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
if (attributes.Length == 0)
s[7] = "AssemblyProduct = ";
else
s[7] = "AssemblyProduct = " + ((AssemblyProductAttribute)attributes[0]).Product;
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
if (attributes.Length == 0)
s[8] = "AssemblyTitle = ";
else
s[8] = "AssemblyTitle = " + ((AssemblyTitleAttribute)attributes[0]).Title;
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTrademarkAttribute), false);
if (attributes.Length == 0)
s[9] = "AssemblyTrademark = ";
else
s[9] = "AssemblyTrademark = " + ((AssemblyTrademarkAttribute)attributes[0]).Trademark;
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyVersionAttribute), false);
if (attributes.Length == 0)
s[10] = "AssemblyVersion = ";
else
s[10] = "AssemblyVersion = " + ((AssemblyVersionAttribute)attributes[0]).Version;
return s;
}
}
#endregion
}
}