0

我有一个用 VB 编写的库。它具有以下枚举:

Public Enum ModelRelationshipTypes
    <Description("For 1 to 0/1 -- i.e. FK is nullable. -- related object is singleton")> _
    IHaveZeroOrOne

    <Description("For 1 to 1  -- related object is singleton")> _
    IHaveOne

    <Description("For 0 to many  (i.e. FK is nullable)  - related object is collection (dictionary)")> _
    IHaveZeroOrMore

    <Description("For 1 to many  (i.e. FK is NOT nullable) - related object is collection (dictionary)")> _
    IHaveOneOrMore

    <Description("For many to many (for true many too many relationships, with a join table that has only FKs as a composite PK) (related object is dictionary)")> _
    IHaveMany
End Enum

但是,当在不同的项目中引用此库时(c# - 但可能无关紧要),对象浏览器不提供描述,如下所示:

在此处输入图像描述

我必须做什么才能显示描述?

4

1 回答 1

1

DescriptonAttribute 是一个运行时属性。您可以将一些文本附加到 Enum 并稍后获取它以向用户扩展/解释其含义。对于 VS/Intellisence 支持,您希望使用三次刻度来创建摘要块:

   Friend Enum MediaInfoItem As Integer

        ''' <summary>
        ''' File Name to be processed
        ''' </summary>
        ''' <remarks></remarks>
        <Description("File name")> FileName
        <Description("File Size")> FileSize
        <Description("Running Time")> Duration
        ...
   End Enum

这里,只有 FileName 会有 Intellisence 信息;使用代码检索描述。它们将显示为 Const,因为它们是。 MediaInfoItem将显示为枚举。

于 2014-03-09T21:06:18.450 回答