This documentation is archived and is not being maintained.

IVsaItems.CreateItem Method

Creates a new instance of one of the IVsaItem types, as defined in the VsaItemType enumeration.

[Visual Basic]
Function CreateItem( _
   ByVal name As String, _
   ByVal itemType As VsaItemType, _
   ByVal itemFlag As VsaItemFlag _
) As IVsaItem
[C#]
IVsaItem CreateItem(
   string name,
 VsaItemType itemType,
 VsaItemFlag itemFlag
);
[C++]
IVsaItem* CreateItem(
   String* name,
 VsaItemType itemType,
 VsaItemFlag itemFlag
);
[JScript]
function CreateItem(
   name : String,
 itemType : VsaItemType,
 itemFlag : VsaItemFlag
) : IVsaItem;

Parameters

name
The name to associate with the new item.

In cases where the item is a reference item type, the name parameter must be exactly the same as the name of the referenced assembly, as set with the IVsaReferenceItem.AssemblyName property. In JScript, however, if you do not specify an AssemblyName, JScript will use the ItemName as the name of the assembly.

itemType
The type of item created, as defined in the VsaItemType enumeration.
itemFlag
The optional flag to specify the initial content of a Code item.

Return Value

Returns a reference to the IVsaItem object created.

Remarks

The newly created object has its IVsaItem.Name property set to the value of the name parameter and is added to the IVsaItems collection with the name parameter used as the index into the collection.

Once created, you can retrieve the item from the collection using calling the Item(string) property passing in the name value, provided the Name property has not been updated.

Use the itemType parameter to set the newly created item's type. The item type is determined by values of the VsaItemType. The following table shows the item types and their corresponding derived classes.

VsaItemType Derived Class
Reference IVsaReferenceItem
AppGlobal IVsaGlobalItem
Code IVsaCodeItem

The itemFlag parameter controls the initial contents of the item, as defined by the VsaItemFlag enumeration when the VsaItemType enumeration is set to Code. For item types other than Code, you must specify None. The following table shows the VsaItemFlag values and the associated initial code for each.

VsaItemFlag Initial Code
None None
Class An empty class
Module An empty module

JScript .NET does not support the VsaItemFlag.Class flag, although users can create their own classes by adding a class declaration to their code. JScript .NET treats the Module and None flags as equivalent, allowing the user to write any code (classes, global methods, and so on) inside the item.

Upon creating an item, the IVsaEngine.IsDirty property returns true until the item is saved.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

IVsaItems Interface | IVsaItems Members | Microsoft.Vsa Namespace | IVsaItem | IVsaReferenceItem.AssemblyName | VsaItemType

Show: