public virtual IVsaItem AddItem(string itemName, VsaItemType type) { VsaItem item = null; if (this.isClosed) { throw new VsaException(VsaError.EngineClosed); } if (null != GetItem(itemName)) { throw new VsaException(VsaError.ItemNameInUse); } switch ((int)type) { case (int)VSAITEMTYPE2.HOSTOBJECT: case (int)VSAITEMTYPE2.HOSTSCOPE: case (int)VSAITEMTYPE2.HOSTSCOPEANDOBJECT: item = new VsaHostObject(this.engine, itemName, (VsaItemType)type, this); if (type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPE || type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPEANDOBJECT) { ((VsaHostObject)item).exposeMembers = true; } if (type == (VsaItemType)VSAITEMTYPE2.HOSTOBJECT || type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPEANDOBJECT) { ((VsaHostObject)item).isVisible = true; } if (this.engine.IsRunning) { ((VsaHostObject)item).Compile(); ((VsaHostObject)item).Run(); } break; case (int)VSAITEMTYPE2.SCRIPTSCOPE: item = new VsaScriptScope(this.engine, itemName, this); break; } if (null != item) { //if (!this.engine.IsRunning) this.items.Add(item); } else { throw new VsaException(VsaError.ItemTypeNotSupported); } return(item); }
public virtual IVsaItem AddItem(string itemName, VsaItemType type){ VsaItem item = null; if (this.isClosed) throw new VsaException(VsaError.EngineClosed); if (null != GetItem(itemName)) throw new VsaException(VsaError.ItemNameInUse); switch ((int)type){ case (int)VSAITEMTYPE2.HOSTOBJECT: case (int)VSAITEMTYPE2.HOSTSCOPE: case (int)VSAITEMTYPE2.HOSTSCOPEANDOBJECT: item = new VsaHostObject(this.engine, itemName, (VsaItemType)type, this); if (type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPE || type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPEANDOBJECT){ ((VsaHostObject)item).exposeMembers = true; } if (type == (VsaItemType)VSAITEMTYPE2.HOSTOBJECT || type == (VsaItemType)VSAITEMTYPE2.HOSTSCOPEANDOBJECT) ((VsaHostObject)item).isVisible = true; if (this.engine.IsRunning){ ((VsaHostObject)item).Compile(); ((VsaHostObject)item).Run(); } break; case (int)VSAITEMTYPE2.SCRIPTSCOPE: item = new VsaScriptScope(this.engine, itemName, this); break; } if (null != item){ //if (!this.engine.IsRunning) this.items.Add(item); }else throw new VsaException(VsaError.ItemTypeNotSupported); return item; }
public IJSVsaItem CreateItem(string name, JSVsaItemType itemType, JSVsaItemFlag itemFlag) { IJSVsaItem item2; if (this.isClosed) { throw new JSVsaException(JSVsaError.EngineClosed); } if (this.engine.IsRunning) { throw new JSVsaException(JSVsaError.EngineRunning); } this.TryObtainLock(); try { if ((itemType != JSVsaItemType.Reference) && !this.engine.IsValidIdentifier(name)) { throw new JSVsaException(JSVsaError.ItemNameInvalid); } foreach (object obj2 in this.items) { if (((VsaItem) obj2).Name.Equals(name)) { throw new JSVsaException(JSVsaError.ItemNameInUse); } } IJSVsaItem item = null; switch (itemType) { case JSVsaItemType.Reference: if (itemFlag != JSVsaItemFlag.None) { throw new JSVsaException(JSVsaError.ItemFlagNotSupported); } break; case JSVsaItemType.AppGlobal: if (itemFlag != JSVsaItemFlag.None) { throw new JSVsaException(JSVsaError.ItemFlagNotSupported); } goto Label_00E3; case JSVsaItemType.Code: if (itemFlag == JSVsaItemFlag.Class) { throw new JSVsaException(JSVsaError.ItemFlagNotSupported); } goto Label_010E; default: goto Label_012A; } item = new VsaReference(this.engine, name); goto Label_012A; Label_00E3: item = new VsaHostObject(this.engine, name, JSVsaItemType.AppGlobal); ((VsaHostObject) item).isVisible = true; goto Label_012A; Label_010E: item = new VsaStaticCode(this.engine, name, itemFlag); this.staticCodeBlockCount++; Label_012A: if (item != null) { this.items.Add(item); } else { throw new JSVsaException(JSVsaError.ItemTypeNotSupported); } this.engine.IsDirty = true; item2 = item; } finally { this.ReleaseLock(); } return item2; }
public IJSVsaItem CreateItem(string name, JSVsaItemType itemType, JSVsaItemFlag itemFlag) { IJSVsaItem item2; if (this.isClosed) { throw new JSVsaException(JSVsaError.EngineClosed); } if (this.engine.IsRunning) { throw new JSVsaException(JSVsaError.EngineRunning); } this.TryObtainLock(); try { if ((itemType != JSVsaItemType.Reference) && !this.engine.IsValidIdentifier(name)) { throw new JSVsaException(JSVsaError.ItemNameInvalid); } foreach (object obj2 in this.items) { if (((VsaItem)obj2).Name.Equals(name)) { throw new JSVsaException(JSVsaError.ItemNameInUse); } } IJSVsaItem item = null; switch (itemType) { case JSVsaItemType.Reference: if (itemFlag != JSVsaItemFlag.None) { throw new JSVsaException(JSVsaError.ItemFlagNotSupported); } break; case JSVsaItemType.AppGlobal: if (itemFlag != JSVsaItemFlag.None) { throw new JSVsaException(JSVsaError.ItemFlagNotSupported); } goto Label_00E3; case JSVsaItemType.Code: if (itemFlag == JSVsaItemFlag.Class) { throw new JSVsaException(JSVsaError.ItemFlagNotSupported); } goto Label_010E; default: goto Label_012A; } item = new VsaReference(this.engine, name); goto Label_012A; Label_00E3: item = new VsaHostObject(this.engine, name, JSVsaItemType.AppGlobal); ((VsaHostObject)item).isVisible = true; goto Label_012A; Label_010E: item = new VsaStaticCode(this.engine, name, itemFlag); this.staticCodeBlockCount++; Label_012A: if (item != null) { this.items.Add(item); } else { throw new JSVsaException(JSVsaError.ItemTypeNotSupported); } this.engine.IsDirty = true; item2 = item; } finally { this.ReleaseLock(); } return(item2); }
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; }
public virtual IVsaItem CreateItem(string name, VsaItemType itemType, VsaItemFlag itemFlag) { if (this.isClosed) { throw new VsaException(VsaError.EngineClosed); } if (this.engine.IsRunning) { throw new VsaException(VsaError.EngineRunning); } this.TryObtainLock(); try{ // The name must be valid for all items except reference items (in which case we don't care) if (itemType != VsaItemType.Reference && !this.engine.IsValidIdentifier(name)) { throw new VsaException(VsaError.ItemNameInvalid); } // Make sure the name isn't already in use foreach (Object vsaItem in this.items) { if (((VsaItem)vsaItem).Name.Equals(name)) { throw new VsaException(VsaError.ItemNameInUse); } } IVsaItem item = null; switch (itemType) { // IVsaReference case VsaItemType.Reference: if (itemFlag != VsaItemFlag.None) { throw new VsaException(VsaError.ItemFlagNotSupported); } // create a wrapper around an assembly item = new VsaReference((VsaEngine)this.engine, name); break; //IVsaGlobalItem case VsaItemType.AppGlobal: if (itemFlag != VsaItemFlag.None) { throw new VsaException(VsaError.ItemFlagNotSupported); } item = new VsaHostObject((VsaEngine)this.engine, name, VsaItemType.AppGlobal); ((VsaHostObject)item).isVisible = true; break; // IVsaCodeItem case VsaItemType.Code: if (itemFlag == VsaItemFlag.Class) { throw new VsaException(VsaError.ItemFlagNotSupported); } item = new VsaStaticCode((VsaEngine)this.engine, name, itemFlag); this.staticCodeBlockCount++; break; } if (item != null) { this.items.Add(item); } else { throw new VsaException(VsaError.ItemTypeNotSupported); } ((VsaEngine)this.engine).IsDirty = true; return(item); }finally{ this.ReleaseLock(); } }
public virtual IVsaItem CreateItem(string name, VsaItemType itemType, VsaItemFlag itemFlag){ if (this.isClosed) throw new VsaException(VsaError.EngineClosed); if (this.engine.IsRunning) throw new VsaException(VsaError.EngineRunning); this.TryObtainLock(); try{ // The name must be valid for all items except reference items (in which case we don't care) if (itemType != VsaItemType.Reference && !this.engine.IsValidIdentifier(name)) throw new VsaException(VsaError.ItemNameInvalid); // Make sure the name isn't already in use foreach (Object vsaItem in this.items){ if (((VsaItem)vsaItem).Name.Equals(name)) throw new VsaException(VsaError.ItemNameInUse); } IVsaItem item = null; switch (itemType){ // IVsaReference case VsaItemType.Reference: if (itemFlag != VsaItemFlag.None) throw new VsaException(VsaError.ItemFlagNotSupported); // create a wrapper around an assembly item = new VsaReference((VsaEngine)this.engine, name); break; //IVsaGlobalItem case VsaItemType.AppGlobal: if (itemFlag != VsaItemFlag.None) throw new VsaException(VsaError.ItemFlagNotSupported); item = new VsaHostObject((VsaEngine)this.engine, name, VsaItemType.AppGlobal); ((VsaHostObject)item).isVisible = true; break; // IVsaCodeItem case VsaItemType.Code: if (itemFlag == VsaItemFlag.Class) throw new VsaException(VsaError.ItemFlagNotSupported); item = new VsaStaticCode((VsaEngine)this.engine, name, itemFlag); this.staticCodeBlockCount++; break; } if (item != null){ this.items.Add(item); }else{ throw new VsaException(VsaError.ItemTypeNotSupported); } ((VsaEngine)this.engine).IsDirty = true; return item; }finally{ this.ReleaseLock(); } }
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); }