Partilhar via


VCFileCodeModel.ValidateMember(String, vsCMElement, String) Method

Definition

Validates that the proposed name is a valid C++ name for the kind given in the context of the parent object.

bool ValidateMember(std::wstring const & bstrName, EnvDTE::vsCMElement Kind, std::wstring const & bstrType = "");
[System.Runtime.InteropServices.DispId(512)]
public bool ValidateMember (string bstrName, EnvDTE.vsCMElement Kind, string bstrType = "");
[<System.Runtime.InteropServices.DispId(512)>]
abstract member ValidateMember : string * EnvDTE.vsCMElement * string -> bool
Public Function ValidateMember (bstrName As String, Kind As vsCMElement, Optional bstrType As String = "") As Boolean

Parameters

bstrName
String

Required. The name of the object being validated.

Kind
vsCMElement

Required. A vsCMElement value representing the type of object to be validated.

bstrType
String

Optional. The type of object being validated.

Returns

true if the proposed name is a valid C++ name; otherwise, false.

Attributes

Examples

This example validates a method name and then, if valid, adds a method with that name to the class.

Sub AddMethod()  
    Dim vcCM As VCCodeModel  
    Dim classElement As VCCodeClass  
    Dim type As String  
    vcCM = DTE.Solution.Item(1).CodeModel  
    classElement = vcCM.Classes.Item(1)  
    type = "int"  
    If (vcCM.ValidateMember("Method1", vsCMElement.vsCMElementFunction, type)) Then  
        classElement.AddFunction("Method1", vsCMFunction.vsCMFunctionFunction, type)  
    End If  
End Sub  

Remarks

See How to: Compile Example Code for Visual C++ Code Model Extensibility for information on how to compile and run this sample.

Applies to