/// <summary> /// Retrieves application metadata and returns it as a string /// </summary> /// <param name="kind">The type of metadata information to return</param> /// <returns></returns> static public string GetApplicationMetaInfo(ApplicationMetaInfo kind) { object[] attributes; Version version; Assembly assembly = Assembly.GetExecutingAssembly(); string value = ""; switch (kind) { case ApplicationMetaInfo.Company: attributes = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); if (attributes.Length > 0) { value = (attributes[0] as AssemblyCompanyAttribute).Company; } break; case ApplicationMetaInfo.Copyright: attributes = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); if (attributes.Length > 0) { value = (attributes[0] as AssemblyCopyrightAttribute).Copyright; } break; case ApplicationMetaInfo.Configuration: attributes = assembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false); if (attributes.Length > 0) { value = (attributes[0] as AssemblyConfigurationAttribute).Configuration; } break; case ApplicationMetaInfo.Version: version = new Version(Application.ProductVersion); value = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build); break; case ApplicationMetaInfo.Revision: version = new Version(Application.ProductVersion); value = string.Format("{0}", version.MinorRevision); break; case ApplicationMetaInfo.ReleaseType: attributes = assembly.GetCustomAttributes(typeof(AssemblyReleaseTypeAttribute), false); if (attributes.Length > 0) { value = (attributes[0] as AssemblyReleaseTypeAttribute).ReleaseType; } break; } return(value); }
/// <summary> /// Retrieves application metadata and returns it as a string /// </summary> /// <param name="kind">The type of metadata information to return</param> /// <returns></returns> public static string GetApplicationMetaInfo(ApplicationMetaInfo kind) { object[] attributes; Version version; Assembly assembly = Assembly.GetExecutingAssembly(); string value = ""; switch (kind) { case ApplicationMetaInfo.Company: attributes = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); if (attributes.Length > 0) value = (attributes[0] as AssemblyCompanyAttribute).Company; break; case ApplicationMetaInfo.Copyright: attributes = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); if (attributes.Length > 0) value = (attributes[0] as AssemblyCopyrightAttribute).Copyright; break; case ApplicationMetaInfo.Configuration: attributes = assembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false); if (attributes.Length > 0) value = (attributes[0] as AssemblyConfigurationAttribute).Configuration; break; case ApplicationMetaInfo.Version: version = new Version(Application.ProductVersion); value = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build); break; case ApplicationMetaInfo.Revision: version = new Version(Application.ProductVersion); value = string.Format("{0}", version.MinorRevision); break; case ApplicationMetaInfo.ReleaseType: attributes = assembly.GetCustomAttributes(typeof(AssemblyReleaseTypeAttribute), false); if (attributes.Length > 0) value = (attributes[0] as AssemblyReleaseTypeAttribute).ReleaseType; break; } return value; }