public bool AddVM(String vmName, String macroBody, String[] argArray, String ns)
{
MacroEntry me = new MacroEntry(this, this, vmName, macroBody, argArray, ns);
me.FromLibrary = registerFromLib;
/*
* the client (VMFactory) will signal to us via
* registerFromLib that we are in startup mode registering
* new VMs from libraries. Therefore, we want to
* addto the library map for subsequent auto reloads
*/
bool isLib = true;
if (registerFromLib)
{
SupportClass.PutElement(libraryMap, ns, ns);
}
else
{
/*
* now, we first want to check to see if this namespace (template)
* is actually a library - if so, we need to use the global namespace
* we don't have to do this when registering, as namespaces should
* be shut off. If not, the default value is true, so we still go
* global
*/
isLib = libraryMap.ContainsKey(ns);
}
if (!isLib && UsingNamespaces(ns))
{
/*
* first, do we have a namespace hash already for this namespace?
* if not, add it to the namespaces, and add the VM
*/
Hashtable local = GetNamespace(ns, true);
SupportClass.PutElement(local, vmName, me);
return true;
}
else
{
/*
* otherwise, add to global template. First, check if we
* already have it to preserve some of the autoload information
*/
MacroEntry exist = (MacroEntry) GetNamespace(GLOBAL_NAMESPACE)[vmName];
if (exist != null)
{
me.FromLibrary = exist.FromLibrary;
}
/*
* now add it
*/
SupportClass.PutElement(GetNamespace(GLOBAL_NAMESPACE), vmName, me);
return true;
}
}