本文整理汇总了C#中IAssemblyInfo.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# IAssemblyInfo.GetName方法的具体用法?C# IAssemblyInfo.GetName怎么用?C# IAssemblyInfo.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAssemblyInfo
的用法示例。
在下文中一共展示了IAssemblyInfo.GetName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateMetadataFromAssembly
/// <summary>
/// Populates the provided metadata map with asembly-level metadata derived
/// from custom attributes.
/// </summary>
/// <remarks>
/// <para>
/// Currently recognized attributes:
/// <list type="bullet">
/// <item><see cref="AssemblyCompanyAttribute" /></item>
/// <item><see cref="AssemblyConfigurationAttribute" /></item>
/// <item><see cref="AssemblyCopyrightAttribute" /></item>
/// <item><see cref="AssemblyDescriptionAttribute" /></item>
/// <item><see cref="AssemblyFileVersionAttribute" /></item>
/// <item><see cref="AssemblyInformationalVersionAttribute" /></item>
/// <item><see cref="AssemblyProductAttribute" /></item>
/// <item><see cref="AssemblyTitleAttribute" /></item>
/// <item><see cref="AssemblyTrademarkAttribute" /></item>
/// <item><see cref="AssemblyVersionAttribute" /></item>
/// </list>
/// </para>
/// </remarks>
/// <param name="assembly">The assembly.</param>
/// <param name="metadataMap">The metadata map.</param>
public static void PopulateMetadataFromAssembly(IAssemblyInfo assembly, PropertyBag metadataMap)
{
metadataMap.Add(MetadataKeys.CodeBase, assembly.Path);
AssemblyCompanyAttribute companyAttribute = AttributeUtils.GetAttribute<AssemblyCompanyAttribute>(assembly, false);
if (companyAttribute != null)
AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Company, companyAttribute.Company);
AssemblyConfigurationAttribute configurationAttribute = AttributeUtils.GetAttribute<AssemblyConfigurationAttribute>(assembly, false);
if (configurationAttribute != null)
AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Configuration, configurationAttribute.Configuration);
AssemblyCopyrightAttribute copyrightAttribute = AttributeUtils.GetAttribute<AssemblyCopyrightAttribute>(assembly, false);
if (copyrightAttribute != null)
AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Copyright, copyrightAttribute.Copyright);
AssemblyDescriptionAttribute descriptionAttribute = AttributeUtils.GetAttribute<AssemblyDescriptionAttribute>(assembly, false);
if (descriptionAttribute != null)
AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Description, descriptionAttribute.Description);
AssemblyFileVersionAttribute fileVersionAttribute = AttributeUtils.GetAttribute<AssemblyFileVersionAttribute>(assembly, false);
if (fileVersionAttribute != null)
AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.FileVersion, fileVersionAttribute.Version);
AssemblyInformationalVersionAttribute informationalVersionAttribute = AttributeUtils.GetAttribute<AssemblyInformationalVersionAttribute>(assembly, false);
if (informationalVersionAttribute != null)
AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.InformationalVersion, informationalVersionAttribute.InformationalVersion);
AssemblyProductAttribute productAttribute = AttributeUtils.GetAttribute<AssemblyProductAttribute>(assembly, false);
if (productAttribute != null)
AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Product, productAttribute.Product);
AssemblyTitleAttribute titleAttribute = AttributeUtils.GetAttribute<AssemblyTitleAttribute>(assembly, false);
if (titleAttribute != null)
AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Title, titleAttribute.Title);
AssemblyTrademarkAttribute trademarkAttribute = AttributeUtils.GetAttribute<AssemblyTrademarkAttribute>(assembly, false);
if (trademarkAttribute != null)
AddMetadataIfNotEmptyOrNull(metadataMap, MetadataKeys.Trademark, trademarkAttribute.Trademark);
// Note: AssemblyVersionAttribute cannot be accessed directly via reflection. It gets baked into the assembly name.
metadataMap.Add(MetadataKeys.Version, assembly.GetName().Version.ToString());
}