|
| 1 | +using System; |
| 2 | +using System.Reflection; |
| 3 | +using System.Windows.Forms; |
| 4 | + |
| 5 | +namespace App |
| 6 | +{ |
| 7 | + partial class About : Form |
| 8 | + { |
| 9 | + public About() |
| 10 | + { |
| 11 | + this.InitializeComponent(); |
| 12 | + this.Text = string.Format("{0} のバージョン情報", this.AssemblyTitle); |
| 13 | + this.labelProductName.Text = this.AssemblyProduct; |
| 14 | + this.labelVersion.Text = String.Format("バージョン {0}", this.AssemblyVersion); |
| 15 | + this.labelCopyright.Text = this.AssemblyCopyright; |
| 16 | + this.labelCompanyName.Text = this.AssemblyCompany; |
| 17 | + this.textBoxDescription.Text = this.AssemblyDescription; |
| 18 | + } |
| 19 | + |
| 20 | + #region アセンブリ属性アクセサー |
| 21 | + |
| 22 | + public string AssemblyTitle |
| 23 | + { |
| 24 | + get |
| 25 | + { |
| 26 | + var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); |
| 27 | + if (attributes.Length > 0) |
| 28 | + { |
| 29 | + var titleAttribute = (AssemblyTitleAttribute) attributes[0]; |
| 30 | + if (titleAttribute.Title != "") |
| 31 | + { |
| 32 | + return titleAttribute.Title; |
| 33 | + } |
| 34 | + } |
| 35 | + return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + public string AssemblyVersion |
| 40 | + { |
| 41 | + get |
| 42 | + { |
| 43 | + return Assembly.GetExecutingAssembly().GetName().Version.ToString(); |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + public string AssemblyDescription |
| 48 | + { |
| 49 | + get |
| 50 | + { |
| 51 | + var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); |
| 52 | + if (attributes.Length == 0) |
| 53 | + { |
| 54 | + return ""; |
| 55 | + } |
| 56 | + return ((AssemblyDescriptionAttribute) attributes[0]).Description; |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + public string AssemblyProduct |
| 61 | + { |
| 62 | + get |
| 63 | + { |
| 64 | + var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); |
| 65 | + if (attributes.Length == 0) |
| 66 | + { |
| 67 | + return ""; |
| 68 | + } |
| 69 | + return ((AssemblyProductAttribute) attributes[0]).Product; |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + public string AssemblyCopyright |
| 74 | + { |
| 75 | + get |
| 76 | + { |
| 77 | + var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); |
| 78 | + if (attributes.Length == 0) |
| 79 | + { |
| 80 | + return ""; |
| 81 | + } |
| 82 | + return ((AssemblyCopyrightAttribute) attributes[0]).Copyright; |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + public string AssemblyCompany |
| 87 | + { |
| 88 | + get |
| 89 | + { |
| 90 | + var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); |
| 91 | + if (attributes.Length == 0) |
| 92 | + { |
| 93 | + return ""; |
| 94 | + } |
| 95 | + return ((AssemblyCompanyAttribute) attributes[0]).Company; |
| 96 | + } |
| 97 | + } |
| 98 | + #endregion |
| 99 | + } |
| 100 | +} |
0 commit comments