Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- using System.Reflection;
- using System.Text;
- namespace ConsoleApplication6 {
- class Program {
- static void Main(string[] args) {
- Console.Out.WriteLine(GetConsoleHeaderString());
- Console.Out.WriteLine("See the '-?' command-line option for usage details.");
- }
- private static string GetConsoleHeaderString() {
- var description = string.Empty;
- var copyright = string.Empty;
- var product = string.Empty;
- var assembly = Assembly.GetExecutingAssembly();
- foreach(var attr in assembly.GetCustomAttributes(false)) {
- var attrType = attr.GetType();
- if(attrType == typeof(AssemblyDescriptionAttribute)) {
- description = ((AssemblyDescriptionAttribute)attr).Description;
- }
- else if(attrType == typeof(AssemblyCopyrightAttribute)) {
- copyright = ((AssemblyCopyrightAttribute)attr).Copyright;
- copyright = copyright.Replace("©","(c)");
- }
- else if(attrType == typeof(AssemblyProductAttribute)) {
- product = ((AssemblyProductAttribute)attr).Product;
- }
- }
- var assemblyName = assembly.GetName();
- // combine the information for output
- var sb = new StringBuilder();
- sb.AppendLine(string.Format(CultureInfo.InvariantCulture,"{0} (version {1})",string.IsNullOrEmpty(product) ? assemblyName.Name : product,assemblyName.Version));
- if(!string.IsNullOrEmpty(description)) { sb.AppendLine(description); }
- if(!string.IsNullOrEmpty(copyright)) { sb.AppendLine(copyright); }
- return sb.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment