Export (0) Print
Expand All

VCCodeNamespace.ValidateMember Method 

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

Namespace: Microsoft.VisualStudio.VCCodeModel
Assembly: Microsoft.VisualStudio.VCCodeModel (in microsoft.visualstudio.vccodemodel.dll)

bool ValidateMember (
	[InAttribute] string bstrName,
	[InAttribute] vsCMElement Kind,
	[OptionalAttribute] [InAttribute] string bstrType
)
boolean ValidateMember (
	/** @attribute InAttribute() */ String bstrName, 
	/** @attribute InAttribute() */ vsCMElement Kind, 
	/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ String bstrType
)
function ValidateMember (
	bstrName : String, 
	Kind : vsCMElement, 
	bstrType : String
) : boolean

Parameters

bstrName

Required. The name of the object being validated.

Kind

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

bstrType

Optional. The type of object being validated.

Return Value

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

See Samples for Visual C++ Code Model Extensibility for information on how to compile and run this sample.

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
Show:
© 2014 Microsoft