public static AssemblyFileInfo FromAssembly(Assembly assembly) { AssemblyFileInfo info = new AssemblyFileInfo(); info.m_AssemblyVersion = assembly.GetName().Version; foreach (object attribute in assembly.GetCustomAttributes(true)) { if (attribute is AssemblyFileVersionAttribute) { info.m_FileVersion = new Version(((AssemblyFileVersionAttribute)attribute).Version); } else if (attribute is AssemblyTitleAttribute) { info.m_Title = ((AssemblyTitleAttribute)attribute).Title; } else if (attribute is AssemblyCompanyAttribute) { info.m_Company = ((AssemblyCompanyAttribute)attribute).Company; } else if (attribute is AssemblyDescriptionAttribute) { info.m_Description = ((AssemblyDescriptionAttribute)attribute).Description; } else if (attribute is AssemblyConfigurationAttribute) { info.m_Configuration = ((AssemblyConfigurationAttribute)attribute).Configuration; } else if (attribute is AssemblyCopyrightAttribute) { info.m_Copyright = ((AssemblyCopyrightAttribute)attribute).Copyright; } else if (attribute is AssemblyCultureAttribute) { info.m_Culture = ((AssemblyCultureAttribute)attribute).Culture; } else if (attribute is GuidAttribute) { info.m_Guid = new Guid(((GuidAttribute)attribute).Value); } else if (attribute is ComVisibleAttribute) { info.m_IsComVisible = ((ComVisibleAttribute)attribute).Value; } else if (attribute is AssemblyProductAttribute) { info.m_Product = ((AssemblyProductAttribute)attribute).Product; } else if (attribute is AssemblyTrademarkAttribute) { info.m_Trademark = ((AssemblyTrademarkAttribute)attribute).Trademark; } else if (attribute is AssemblyInformationalVersionAttribute) { info.m_InformalVersion = new Version(((AssemblyInformationalVersionAttribute)attribute).InformationalVersion); } } return(info); }
public static AssemblyFileInfo FromFile(string assemblyFileName) { Assembly assembly = Assembly.LoadFile(assemblyFileName); return(AssemblyFileInfo.FromAssembly(assembly)); }
public static AssemblyFileInfo FromAssembly(Assembly assembly) { AssemblyFileInfo info = new AssemblyFileInfo(); info.m_AssemblyVersion = assembly.GetName().Version; foreach (object attribute in assembly.GetCustomAttributes(true)) { if (attribute is AssemblyFileVersionAttribute) { info.m_FileVersion = new Version(((AssemblyFileVersionAttribute)attribute).Version); } else if (attribute is AssemblyTitleAttribute) { info.m_Title = ((AssemblyTitleAttribute)attribute).Title; } else if (attribute is AssemblyCompanyAttribute) { info.m_Company = ((AssemblyCompanyAttribute)attribute).Company; } else if (attribute is AssemblyDescriptionAttribute) { info.m_Description = ((AssemblyDescriptionAttribute)attribute).Description; } else if (attribute is AssemblyConfigurationAttribute) { info.m_Configuration = ((AssemblyConfigurationAttribute)attribute).Configuration; } else if (attribute is AssemblyCopyrightAttribute) { info.m_Copyright = ((AssemblyCopyrightAttribute)attribute).Copyright; } else if (attribute is AssemblyCultureAttribute) { info.m_Culture = ((AssemblyCultureAttribute)attribute).Culture; } else if (attribute is GuidAttribute) { info.m_Guid = new Guid(((GuidAttribute)attribute).Value); } else if (attribute is ComVisibleAttribute) { info.m_IsComVisible = ((ComVisibleAttribute)attribute).Value; } else if (attribute is AssemblyProductAttribute) { info.m_Product = ((AssemblyProductAttribute)attribute).Product; } else if (attribute is AssemblyTrademarkAttribute) { info.m_Trademark = ((AssemblyTrademarkAttribute)attribute).Trademark; } else if (attribute is AssemblyInformationalVersionAttribute) { info.m_InformalVersion = new Version(((AssemblyInformationalVersionAttribute)attribute).InformationalVersion); } } return info; }