An object representing a namespace element in the source code of a solution.
Namespace:  Microsoft.VisualStudio.VCCodeModel
Assembly:  Microsoft.VisualStudio.VCCodeModel (in Microsoft.VisualStudio.VCCodeModel.dll)
Syntax
声明
<GuidAttribute("4853EB51-640F-4A98-A6CF-B43C3ECFA8A5")> _
Public Interface VCCodeNamespace
[GuidAttribute("4853EB51-640F-4A98-A6CF-B43C3ECFA8A5")]
public interface VCCodeNamespace
[GuidAttribute(L"4853EB51-640F-4A98-A6CF-B43C3ECFA8A5")]
public interface class VCCodeNamespace
[<GuidAttribute("4853EB51-640F-4A98-A6CF-B43C3ECFA8A5")>]
type VCCodeNamespace =  interface end
public interface VCCodeNamespace
The VCCodeNamespace type exposes the following members.
Properties
| Name | Description | |
|---|---|---|
| .gif) | BodyText | Gets or sets the body text of the object. | 
| .gif) | Children | Gets a collection of objects contained within this code construct. | 
| .gif) | Classes | Gets a collection of classes for the object. | 
| .gif) | CodeModel | Gets the VCCodeModel object for the project. | 
| .gif) | Collection | Gets the collection containing the object supporting this property or contained within this code construct. | 
| .gif) | Comment | Gets or sets the comment associated with the code element. | 
| .gif) | DeclarationText | Gets or sets the declaration of the object. | 
| .gif) | DisplayName | Gets the name used in the user interface for this output group. | 
| .gif) | DocComment | Gets the document comment for the current code model element. | 
| .gif) | DTE | Gets the top-level extensibility object. | 
| .gif) | EndPoint | Gets the edit point that is the location of the end of the code item. | 
| .gif) | EndPointOf | Returns the end point of the parent object. | 
| .gif) | Enums | Gets a collection of enumerations for the object. | 
| .gif) | Extender | Returns the requested Extender object if it is available for this object. | 
| .gif) | ExtenderCATID | Gets the Extender category ID (CATID) for the object. | 
| .gif) | ExtenderNames | Gets a list of available Extenders for the object. | 
| .gif) | File | Gets the file in which the object is declared. | 
| .gif) | FullName | Gets the full path and name of the object's file. | 
| .gif) | Functions | Gets a collection of functions for the object. | 
| .gif) | InfoLocation | Gets the capabilities of the code model. | 
| .gif) | Interfaces | Gets the collection of interfaces for the object. | 
| .gif) | IsCaseSensitive | Gets whether a code element is case-sensitive. | 
| .gif) | IsCodeType | Gets a value indicating whether a CodeType object can be obtained from this object. | 
| .gif) | IsInjected | Gets whether a code element has been injected by an attribute or macro expansion. | 
| .gif) | IsReadOnly | Gets whether the file containing the object is read-only. | 
| .gif) | IsZombie | Gets whether the object exists. | 
| .gif) | Kind | Gets an enumeration indicating the type of object. | 
| .gif) | Language | Gets the programming language used to author the code. | 
| .gif) | Location | Returns the location of the object declaration. | 
| .gif) | Macros | Gets the collection of macros (#define statements) for the object. | 
| .gif) | Maps | Gets the collection of maps for the object. | 
| .gif) | Members | Gets a collection of items contained by this element. | 
| .gif) | Name | Gets or sets the name of the object. | 
| .gif) | Namespaces | Gets the collection of namespaces for the object. | 
| .gif) | Parent | Gets the immediate parent object of a given object. | 
| .gif) | Picture | Gets a picture automation object to be used as an icon in the user interface. | 
| .gif) | Project | Gets the Project object associated with the object. | 
| .gif) | ProjectItem | Gets the ProjectItem object associated with the given object. | 
| .gif) | References | Not currently implemented. | 
| .gif) | StartPoint | Gets a TextPoint object that defines the beginning of the code item. | 
| .gif) | StartPointOf | Gets the start point of the object. | 
| .gif) | Structs | Gets the collection of structure elements for the object. | 
| .gif) | Typedefs | Gets the collection of Typedef elements for the object. | 
| .gif) | Unions | Gets the collection of union elements for the object. | 
| .gif) | Variables | Gets the collection of variables for the object. | 
Top
Methods
| Name | Description | |
|---|---|---|
| .gif) | AddClass | Creates a new class code construct and inserts the code in the correct location. | 
| .gif) | AddDelegate | Creates a new delegate code construct and inserts the code in the correct location. | 
| .gif) | AddEnum | Creates a new enumeration code construct and inserts the code in the correct location. | 
| .gif) | AddFunction | Creates a new function code construct and inserts the code in the correct location. | 
| .gif) | AddInterface | Creates a new interface code construct and inserts the code in the correct location. | 
| .gif) | AddMap | Adds a map to the object. | 
| .gif) | AddNamespace | Creates a new namespace code construct and inserts the code in the correct location. | 
| .gif) | AddStruct | Creates a new structure code construct and inserts the code in the correct location. | 
| .gif) | AddTypedef | Adds a typedef statement to the object. | 
| .gif) | AddUnion | Adds a union statement to the object. | 
| .gif) | AddVariable | Creates a new variable code construct and inserts the code in the correct location. | 
| .gif) | GetEndPoint | Gets a TextPoint object that marks the end of the code element definition. | 
| .gif) | GetStartPoint | Gets a TextPoint object that defines the beginning of the code element definition. | 
| .gif) | IsSelf | Determines if the specified code element is the same as another code element. | 
| .gif) | Remove | Removes the specified project from the solution. | 
| .gif) | ValidateMember | Validates that the proposed name is a valid C++ name for the kind given in the context of the object. | 
Top
Remarks
The VCCodeNamespace object represents namespace declarations and is a superset of the VCCodeElement object.
备注
A large part of the functionality of this object is provided by the Visual Studio CodeNamespace object. For more information, see CodeNamespace object.
See How to: Compile Example Code for Visual C++ Code Model Extensibility for information on how to compile and run this sample.
Examples
This example retrieves the namespaces of the current solution and displays each name in a message box.
Sub AllNamespaces()
    Dim codeModel As VCCodeModel
    codeModel = DTE.Solution.Item(1).CodeModel
    Dim namespace As VCCodeNamespace
    For Each namespace In codeModel.Namespaces
        MsgBox(namespace.DisplayName)
    Next
End Sub