当前位置: 首页>>代码示例>>C#>>正文


C# IAssemblyInfo.GetName方法代码示例

本文整理汇总了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());
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:66,代码来源:ModelUtils.cs


注:本文中的IAssemblyInfo.GetName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。