共用方式為


IContentTypeRegistryService.AddContentType 方法

建立新的內容類型,並予以加入。

命名空間:  Microsoft.VisualStudio.Utilities
組件:  Microsoft.VisualStudio.CoreUtility (在 Microsoft.VisualStudio.CoreUtility.dll 中)

語法

'宣告
Function AddContentType ( _
    typeName As String, _
    baseTypeNames As IEnumerable(Of String) _
) As IContentType
IContentType AddContentType(
    string typeName,
    IEnumerable<string> baseTypeNames
)
IContentType^ AddContentType(
    String^ typeName, 
    IEnumerable<String^>^ baseTypeNames
)
abstract AddContentType : 
        typeName:string * 
        baseTypeNames:IEnumerable<string> -> IContentType
function AddContentType(
    typeName : String, 
    baseTypeNames : IEnumerable<String>
) : IContentType

參數

  • typeName
    類型:String

    內容類型的名稱。

  • baseTypeNames
    類型:IEnumerable<String>

    要當做基底內容類型之內容類型名稱的清單。 選擇項。

傳回值

類型:Microsoft.VisualStudio.Utilities.IContentType
IContentType

例外狀況

例外狀況 條件
InvalidOperationException

typeName或其中一個baseTypeNames名稱UnknownContentType,或已存在的內容類型,或其中一個基底型別可能會引入循環基底型別關聯性。

ArgumentException

typeName 是 nullnull 參考 (即 Visual Basic 中的 Nothing) 或空的。

.NET Framework 安全性

請參閱

參考

IContentTypeRegistryService 介面

Microsoft.VisualStudio.Utilities 命名空間