Skip to main content

Services

Host.Services provides inter-script singleton lookup. A script registers a service via classfactory.xml with category="FrameworkService", and other scripts retrieve it by its class ID GUID.

Methods:

MethodReturnsParametersDescription
Host.Services.getInstance(classID)objectclassID — GUID string from the framework service's class factoryRetrieve a registered singleton service by class ID
var service = Host.Services.getInstance("{00000000-0000-0000-0000-000000000000}");
if (service) {
service.someMethod();
}

Registering a Service

Add a ScriptClass with category="FrameworkService" to your classfactory.xml:

<ScriptClass
classID="{00000000-0000-0000-0000-000000000000}"
category="FrameworkService"
name="My Service"
sourceFile="service.js"
functionName="createMyServiceInstance">
</ScriptClass>

The associated script must implement IComponent or IExtensionHandler to serve as the singleton object retrieved by other scripts.