Exemple #1
0
        static App()
        {
            Assembly asm = Assembly.GetCallingAssembly();

            Name    = asm.GetName().Name;
            Version = asm.GetName().Version.ToString(3);
            Banner  = $"{Name} v{Version}";

            Type type = typeof(AssemblyDescriptionAttribute);

            if (AssemblyDescriptionAttribute.IsDefined(asm, type))
            {
                AssemblyDescriptionAttribute a =
                    (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(asm, type);
                Banner += " - " + a.Description;
            }

            type = typeof(AssemblyCopyrightAttribute);
            if (AssemblyCopyrightAttribute.IsDefined(asm, type))
            {
                AssemblyCopyrightAttribute a =
                    (AssemblyCopyrightAttribute)AssemblyCopyrightAttribute.GetCustomAttribute(asm, type);
                Banner += Environment.NewLine + a.Copyright.Replace("©", "(c)");
            }
        }
Exemple #2
0
        private void readAssembly()
        {
            Assembly me = Assembly.GetExecutingAssembly();

            this.name = me.GetName().Name + " v" + me.GetName().Version;
            Type type = typeof(CustomAssemblyVariable);

            if (CustomAssemblyVariable.IsDefined(me, type))
            {
                string releaseType = ((CustomAssemblyVariable)CustomAssemblyVariable.GetCustomAttribute(
                                          me,
                                          type
                                          )).value;
                if (releaseType != "Release")
                {
                    this.name += " - " + releaseType + " version!";
                }
            }
            type = typeof(AssemblyDescriptionAttribute);
            if (AssemblyDescriptionAttribute.IsDefined(me, type))
            {
                this.desc = ((AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(me, type)).Description;
            }
            else
            {
                this.desc = "N/A";
            }
        }
 public static string GetAssemblyDescription(Assembly asm)
 {
     if (asm == null)
     {
         return(string.Empty);
     }
     if (AssemblyDescriptionAttribute.IsDefined(asm, typeof(AssemblyDescriptionAttribute)))
     {
         AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute)
                                                    AssemblyDescriptionAttribute.GetCustomAttribute(asm, typeof(AssemblyDescriptionAttribute));
         return(description.Description);
     }
     return(string.Empty);
 }
Exemple #4
0
        public static string GetDescription()
        {
            //Type of attribute that is desired
            Type type = typeof(AssemblyDescriptionAttribute);

            //Is there an attribute of this type already defined?
            if (AssemblyDescriptionAttribute.IsDefined(Assembly.GetExecutingAssembly(), type))
            {
                //if there is, get attribute of desired type
                AssemblyDescriptionAttribute assemblyDescriptionAttribute = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), type);

                return(assemblyDescriptionAttribute.Description);
            }

            return(null);
        }
Exemple #5
0
        internal void EmitHeader()
        {
            LogMessage(LogLevel.Info, "".PadRight(120, '─'), new object[] { });

            //! Type of attribute that is desired
            Type type = typeof(AssemblyDescriptionAttribute);

            Assembly asm = Assembly.GetExecutingAssembly();

            //! Is there an attribute of this type already defined?
            if (AssemblyDescriptionAttribute.IsDefined(asm, type))
            {
                //! if there is, get attribute of desired type
                AssemblyDescriptionAttribute ada = (AssemblyDescriptionAttribute)AssemblyDescriptionAttribute.GetCustomAttribute(asm, type);

                LogMessage(LogLevel.Info, ada.Description, new object[] { });
            }

            FileVersionInfo vi = FileVersionInfo.GetVersionInfo(asm.Location);

            LogMessage(LogLevel.Info, "{0} v{1}", new object[] { vi.ProductName.ToString(), vi.FileVersion.ToString() });
            LogMessage(LogLevel.Info, vi.LegalCopyright, new object[] { });
            LogMessage(LogLevel.Info, "".PadRight(120, '─'), new object[] { });
        }