andrew4582

About

Aug 2nd, 2011
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 KB | None | 0 0
  1. using System;
  2. using System.Reflection;
  3.  
  4. namespace System {
  5.     /// <summary>
  6.     /// Assembly metadata
  7.     /// </summary>
  8.     public sealed class About {
  9.         #region Fields
  10.  
  11.         public static readonly About Fx = new About(typeof(About).Assembly);
  12.  
  13.         public readonly Version Version;
  14.         public readonly string FullName;
  15.         public readonly string Name;
  16.         public readonly string Configuration;
  17.         public readonly string Copyright;
  18.         public readonly string Title;
  19.         public readonly string Description;
  20.         public readonly string Company;
  21.  
  22.         #endregion Fields
  23.  
  24.         #region Init
  25.  
  26.         /// <summary>
  27.         /// Ctor
  28.         /// </summary>
  29.         /// <param name="assembly"></param>
  30.         public About(Assembly assembly) {
  31.             if(assembly == null) {
  32.                 throw new ArgumentNullException("assembly");
  33.             }
  34.  
  35.             AssemblyName name = assembly.GetName();
  36.  
  37.             this.FullName = assembly.FullName;
  38.             this.Version = name.Version;
  39.             this.Name = name.Name;
  40.  
  41.             AssemblyCopyrightAttribute copyright = Attribute.GetCustomAttribute(assembly,typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;
  42.             this.Copyright = (copyright != null) ? copyright.Copyright : String.Empty;
  43.  
  44.             AssemblyDescriptionAttribute description = Attribute.GetCustomAttribute(assembly,typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute;
  45.             this.Description = (description != null) ? description.Description : String.Empty;
  46.  
  47.             AssemblyTitleAttribute title = Attribute.GetCustomAttribute(assembly,typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute;
  48.             this.Title = (title != null) ? title.Title : String.Empty;
  49.  
  50.             AssemblyCompanyAttribute company = Attribute.GetCustomAttribute(assembly,typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
  51.             this.Company = (company != null) ? company.Company : String.Empty;
  52.  
  53.             AssemblyConfigurationAttribute config = Attribute.GetCustomAttribute(assembly,typeof(AssemblyConfigurationAttribute)) as AssemblyConfigurationAttribute;
  54.             this.Configuration = (config != null) ? config.Configuration : String.Empty;
  55.         }
  56.  
  57.         #endregion Init
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment