Compartilhar via


VCCodeEnum.AddMember Method

Creates a new member code construct and inserts the code in the correct location.

Namespace:  Microsoft.VisualStudio.VCCodeModel
Assembly:  Microsoft.VisualStudio.VCCodeModel (in Microsoft.VisualStudio.VCCodeModel.dll)

Syntax

'Declaration
Function AddMember ( _
    Name As String, _
    Value As Object, _
    Position As Object _
) As CodeVariable
CodeVariable AddMember(
    string Name,
    Object Value,
    Object Position
)
CodeVariable^ AddMember(
    String^ Name, 
    Object^ Value, 
    Object^ Position
)
abstract AddMember : 
        Name:string * 
        Value:Object * 
        Position:Object -> CodeVariable
function AddMember(
    Name : String, 
    Value : Object, 
    Position : Object
) : CodeVariable

Parameters

  • Position
    Type: System.Object

    Optional. Default = 0. The code element after which to add the new element. If the value is a CodeElement, then the new element is added immediately after it.

    If the value is a Long data type, then AddMember indicates the element after which to add the new element.

    Because collections begin their count at 1, passing 0 indicates that the new element should be placed at the beginning of the collection. A value of -1 means the element should be placed at the end.

Return Value

Type: EnvDTE.CodeVariable
A CodeVariable object.

Remarks

AddMember adds a member to the enumeration and returns a CodeVariable object with IsConstant set to true.

When setting Value to a string, AddMember inserts any required syntax, such as equal signs or semicolons if the variable does not already have an initialization expression. Depending on the languages and any syntactic or semantic checks it performs on the passed-in string, setting this argument may fail. Languages are not required to check the string, and because the string is necessarily language-dependent, setting this argument could result in undefined behavior if the string has any ill-formed content.

When setting Value to a CodeElement, the decision as to whether the CodeElement must be newly created depends on the language implementation of the code model. Some languages may implement copying semantics if you pass in a code element that is already in a source file.

The correctness of the arguments is determined by the language behind the code model.

.NET Framework Security

See Also

Reference

VCCodeEnum Interface

Microsoft.VisualStudio.VCCodeModel Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples