1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Text; 7 using System.Windows.Forms; 8 using System.Reflection; 9 10 namespace distribution_explorer 11 { /// namespace distribution_explorer 12 public partial class distexSplash : Form 13 { /// Splash distexSplash()14 public distexSplash() 15 { 16 InitializeComponent(); 17 this.labelApplicationTitle.Text = AssemblyTitle; 18 this.labelApplicationDescription.Text = AssemblyDescription; 19 this.labelApplicationCopyright.Text = AssemblyCopyright; 20 this.labelApplicationVersion.Text = "Version " + AssemblyVersion; 21 } 22 23 #region Assembly Attribute Accessors 24 /// get AssemblyTitle 25 public string AssemblyTitle 26 { 27 get 28 { 29 // Get all Title attributes on this assembly 30 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); 31 // If there is at least one Title attribute 32 if (attributes.Length > 0) 33 { 34 // Select the first one 35 AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; 36 // If it is not an empty string, return it 37 if (titleAttribute.Title != "") 38 return titleAttribute.Title; 39 } 40 // If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name 41 return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); 42 } 43 } 44 /// get AssemblyVersion 45 public string AssemblyVersion 46 { 47 get 48 { 49 return Assembly.GetExecutingAssembly().GetName().Version.ToString(); 50 } 51 } 52 53 //public string AssemblyGuid 54 //{ // error CS0117: 'System.Reflection.AssemblyName' does not contain a definition for 'Guid' 55 // get 56 // { 57 // return Assembly.GetExecutingAssembly().GetName().Guid.ToString(); 58 // } 59 //} 60 /// get AssemblyDescription 61 public string AssemblyDescription 62 { 63 get 64 { 65 // Get all Description attributes on this assembly 66 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); 67 // If there aren't any Description attributes, return an empty string 68 if (attributes.Length == 0) 69 return ""; 70 // If there is a Description attribute, return its value 71 return ((AssemblyDescriptionAttribute)attributes[0]).Description; 72 } 73 } 74 /// get AssemblyProduct 75 public string AssemblyProduct 76 { 77 get 78 { 79 // Get all Product attributes on this assembly 80 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); 81 // If there aren't any Product attributes, return an empty string 82 if (attributes.Length == 0) 83 return ""; 84 // If there is a Product attribute, return its value 85 return ((AssemblyProductAttribute)attributes[0]).Product; 86 } 87 } 88 /// get AssemblyCopyright 89 public string AssemblyCopyright 90 { 91 get 92 { 93 // Get all Copyright attributes on this assembly 94 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); 95 // If there aren't any Copyright attributes, return an empty string 96 if (attributes.Length == 0) 97 return ""; 98 // If there is a Copyright attribute, return its value 99 return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; 100 } 101 } 102 /// get AssemblyCompany 103 public string AssemblyCompany 104 { 105 get 106 { 107 // Get all Company attributes on this assembly 108 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); 109 // If there aren't any Company attributes, return an empty string 110 if (attributes.Length == 0) 111 return ""; 112 // If there is a Company attribute, return its value 113 return ((AssemblyCompanyAttribute)attributes[0]).Company; 114 } 115 } 116 #endregion 117 labelApplicationVersion_Click(object sender, EventArgs e)118 private void labelApplicationVersion_Click(object sender, EventArgs e) 119 { 120 121 } 122 } 123 } 124 125 126 127