public virtual IJSVsaItem AddItem(string itemName, JSVsaItemType type)
        {
            VsaItem item = null;
            if (this.isClosed)
            {
                throw new JSVsaException(JSVsaError.EngineClosed);
            }
            if (this.GetItem(itemName) != null)
            {
                throw new JSVsaException(JSVsaError.ItemNameInUse);
            }
            switch (((int) type))
            {
                case 0x10:
                case 0x11:
                case 0x12:
                    item = new VsaHostObject(base.engine, itemName, type, this);
                    if ((type == ((JSVsaItemType) 0x11)) || (type == ((JSVsaItemType) 0x12)))
                    {
                        ((VsaHostObject) item).exposeMembers = true;
                    }
                    if ((type == ((JSVsaItemType) 0x10)) || (type == ((JSVsaItemType) 0x12)))
                    {
                        ((VsaHostObject) item).isVisible = true;
                    }
                    if (base.engine.IsRunning)
                    {
                        ((VsaHostObject) item).Compile();
                        ((VsaHostObject) item).Run();
                    }
                    break;

                case 0x13:
                    item = new VsaScriptScope(base.engine, itemName, this);
                    break;

                case 20:
                    item = new VsaScriptCode(base.engine, itemName, type, this);
                    break;

                case 0x15:
                    if (!base.engine.IsRunning)
                    {
                        throw new JSVsaException(JSVsaError.EngineNotRunning);
                    }
                    item = new VsaScriptCode(base.engine, itemName, type, this);
                    break;

                case 0x16:
                    if (!base.engine.IsRunning)
                    {
                        throw new JSVsaException(JSVsaError.EngineNotRunning);
                    }
                    item = new VsaScriptCode(base.engine, itemName, type, this);
                    break;
            }
            if (item == null)
            {
                throw new JSVsaException(JSVsaError.ItemTypeNotSupported);
            }
            this.items.Add(item);
            return item;
        }
Exemple #2
0
        public virtual IJSVsaItem AddItem(string itemName, JSVsaItemType type)
        {
            VsaItem item = null;

            if (this.isClosed)
            {
                throw new JSVsaException(JSVsaError.EngineClosed);
            }
            if (this.GetItem(itemName) != null)
            {
                throw new JSVsaException(JSVsaError.ItemNameInUse);
            }
            switch (((int)type))
            {
            case 0x10:
            case 0x11:
            case 0x12:
                item = new VsaHostObject(base.engine, itemName, type, this);
                if ((type == ((JSVsaItemType)0x11)) || (type == ((JSVsaItemType)0x12)))
                {
                    ((VsaHostObject)item).exposeMembers = true;
                }
                if ((type == ((JSVsaItemType)0x10)) || (type == ((JSVsaItemType)0x12)))
                {
                    ((VsaHostObject)item).isVisible = true;
                }
                if (base.engine.IsRunning)
                {
                    ((VsaHostObject)item).Compile();
                    ((VsaHostObject)item).Run();
                }
                break;

            case 0x13:
                item = new VsaScriptScope(base.engine, itemName, this);
                break;

            case 20:
                item = new VsaScriptCode(base.engine, itemName, type, this);
                break;

            case 0x15:
                if (!base.engine.IsRunning)
                {
                    throw new JSVsaException(JSVsaError.EngineNotRunning);
                }
                item = new VsaScriptCode(base.engine, itemName, type, this);
                break;

            case 0x16:
                if (!base.engine.IsRunning)
                {
                    throw new JSVsaException(JSVsaError.EngineNotRunning);
                }
                item = new VsaScriptCode(base.engine, itemName, type, this);
                break;
            }
            if (item == null)
            {
                throw new JSVsaException(JSVsaError.ItemTypeNotSupported);
            }
            this.items.Add(item);
            return(item);
        }