Пример #1
0
        static EntryAssemblyInformation()
        {
            EntryAssembly = Assembly.GetEntryAssembly();

            foreach (object obj in EntryAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), true))
            {
                Title = (string)typeof(AssemblyTitleAttribute).GetProperty("Title").GetValue(obj, null);
            }

            foreach (object obj in EntryAssembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), true))
            {
                Description = ((AssemblyDescriptionAttribute)obj).Description;
            }

            foreach (object obj in EntryAssembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true))
            {
                Company = ((AssemblyCompanyAttribute)obj).Company;
            }

            foreach (object obj in EntryAssembly.GetCustomAttributes(typeof(AssemblyProductAttribute), true))
            {
                Product = ((AssemblyProductAttribute)obj).Product;
            }

            foreach (object obj in EntryAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), true))
            {
                Copyright = ((AssemblyCopyrightAttribute)obj).Copyright;
            }

            Version = EntryAssembly.GetName().Version.ToString();

            StartupPath = System.Windows.Forms.Application.StartupPath;
        }
Пример #2
0
 private static T getAttribute <T> () where T : Attribute
 {
     object[] attributes = EntryAssembly.GetCustomAttributes(typeof(T), false);
     if (attributes.Length == 0)
     {
         return(null);
     }
     return(attributes[0] as T);
 }