public IJSVsaItem this[string itemName] { [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")] get { if (this.isClosed) { throw new JSVsaException(JSVsaError.EngineClosed); } if (itemName != null) { int num = 0; int count = this.items.Count; while (num < count) { IJSVsaItem item = (IJSVsaItem)this.items[num]; if (item.Name.Equals(itemName)) { return(item); } num++; } } throw new JSVsaException(JSVsaError.ItemNotFound); } }
public virtual bool Compile() { bool isEngineCompiled; this.TryObtainLock(); try { this.Preconditions(Pre.EngineInitialised | Pre.RootNamespaceSet | Pre.EngineNotRunning | Pre.EngineNotClosed); bool flag = false; int num = 0; int count = this.vsaItems.Count; while (!flag && (num < count)) { IJSVsaItem item1 = this.vsaItems[num]; flag = this.vsaItems[num].ItemType == JSVsaItemType.Code; num++; } if (!flag) { throw this.Error(JSVsaError.EngineClosed); } try { this.ResetCompiledState(); this.isEngineCompiled = this.DoCompile(); } catch (JSVsaException) { throw; } catch (Exception exception) { throw new JSVsaException(JSVsaError.InternalCompilerError, exception.ToString(), exception); } if (this.isEngineCompiled) { this.haveCompiledState = true; this.failedCompilation = false; this.compiledRootNamespace = this.rootNamespace; } isEngineCompiled = this.isEngineCompiled; } finally { this.ReleaseLock(); } return(isEngineCompiled); }
public virtual void RemoveItem(IJSVsaItem item) { int num = 0; int count = this.items.Count; while (num < count) { VsaItem item2 = (VsaItem)this.items[num]; if (item2 == item) { item2.Remove(); this.items.Remove(num); return; } num++; } throw new JSVsaException(JSVsaError.ItemNotFound); }
public void Remove(string itemName) { if (this.isClosed) { throw new JSVsaException(JSVsaError.EngineClosed); } this.TryObtainLock(); try { if (itemName == null) { throw new ArgumentNullException("itemName"); } int index = 0; int count = this.items.Count; while (index < count) { IJSVsaItem item = (IJSVsaItem)this.items[index]; if (item.Name.Equals(itemName)) { ((VsaItem)item).Remove(); this.items.RemoveAt(index); this.engine.IsDirty = true; if (item is VsaStaticCode) { this.staticCodeBlockCount--; } return; } index++; } throw new JSVsaException(JSVsaError.ItemNotFound); } finally { this.ReleaseLock(); } }
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 void RemoveItem(IJSVsaItem item) { int num = 0; int count = this.items.Count; while (num < count) { VsaItem item2 = (VsaItem) this.items[num]; if (item2 == item) { item2.Remove(); this.items.Remove(num); return; } num++; } throw new JSVsaException(JSVsaError.ItemNotFound); }