IVsaGlobalItem.TypeString Property
Gets or sets the type of the global item.
public: _property String* get_TypeString();
public: _property void set_TypeString(String* value);
public string TypeString { get; set; }
Public Property Let TypeString (
ByVal value As String
)
Return Value
Returns the item type of the global item.
Remarks
Preconditions for setting this property are that the engine must not be closed and the engine must not be running, and the TypeString property's value must be a valid type. However, checks or validation of type are not performed until compile time.
A callback to the IVsaSite.GetGlobalInstance method is used to get an instance of the type when the IVsaEngine.Run method is called.
The following table shows the exception that the TypeString property can throw.
Exception Type |
Condition |
---|---|
EngineClosed |
The IVsaEngine.Close method has been called and the engine is closed. |
EngineRunning |
The engine is currently running. |
EngineBusy |
The engine is currently servicing another thread. |
Example
The following example shows how to add a global reference to the MyApplication object to the engine. The MyApplication class has a method called CreateOrder, and is added to the engine with the name Application. The code run by the engine can access this object as if it were a built-in object.
In the host source code, you will find code like the following:
// Get a reference to the items collection.
var items : IVsaItems = myEngine.Items;
// Create a new global item and set its type name.
var glob : IVsaGlobalItem = items.CreateItem("Application",
VsaItemType.AppGlobal, VsaItemFlag.None);
glob.TypeString = "MyApplication";
In user-supplied code that is added to the engine:
// In the user code include this:
function DoStuff ()
{
// Call the CreateOrder method, qualified with the name
// of the global object specified in the CreateItem
// method ("Application" in this case).
Applcation.CreateOrder();
}