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; }
internal void TryToAddImplicitAssemblyReference(String name){ if (!this.autoRef) return; String key; SimpleHashtable implictAssemblyCache = this.implicitAssemblyCache; if (implicitAssemblyCache == null) { //Populate cache with things that should not be autoref'd. Canonical form is lower case without extension. implicitAssemblyCache = new SimpleHashtable(50); //PEFileName always includes an extension and is never NULL. implicitAssemblyCache[Path.GetFileNameWithoutExtension(this.PEFileName).ToLower(CultureInfo.InvariantCulture)] = true; foreach (Object item in this.vsaItems){ VsaReference assemblyReference = item as VsaReference; if (assemblyReference == null || assemblyReference.AssemblyName == null) continue; key = Path.GetFileName(assemblyReference.AssemblyName).ToLower(CultureInfo.InvariantCulture); if (key.EndsWith(".dll")) key = key.Substring(0, key.Length-4); implicitAssemblyCache[key] = true; } this.implicitAssemblyCache = implicitAssemblyCache; } key = name.ToLower(CultureInfo.InvariantCulture); if (implicitAssemblyCache[key] != null) return; implicitAssemblyCache[key] = true; try{ VsaReference assemblyReference = new VsaReference(this, name + ".dll"); if (assemblyReference.Compile(false)){ ArrayList implicitAssemblies = this.implicitAssemblies; if (implicitAssemblies == null) { implicitAssemblies = new ArrayList(); this.implicitAssemblies = implicitAssemblies; } implicitAssemblies.Add(assemblyReference.Assembly); } }catch(VsaException){ } }
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 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(); } }
internal void TryToAddImplicitAssemblyReference(string name) { if (this.autoRef) { string str; if (this.implicitAssemblyCache == null) { this.implicitAssemblyCache = new SimpleHashtable(50); this.implicitAssemblyCache[Path.GetFileNameWithoutExtension(this.PEFileName).ToLowerInvariant()] = true; foreach (object obj2 in base.vsaItems) { VsaReference reference = obj2 as VsaReference; if ((reference != null) && (reference.AssemblyName != null)) { str = Path.GetFileName(reference.AssemblyName).ToLowerInvariant(); if (str.EndsWith(".dll", StringComparison.Ordinal)) { str = str.Substring(0, str.Length - 4); } this.implicitAssemblyCache[str] = true; } } this.implicitAssemblyCache = this.implicitAssemblyCache; } str = name.ToLowerInvariant(); if (this.implicitAssemblyCache[str] == null) { this.implicitAssemblyCache[str] = true; try { VsaReference reference2 = new VsaReference(this, name + ".dll"); if (reference2.Compile(false)) { ArrayList implicitAssemblies = this.implicitAssemblies; if (implicitAssemblies == null) { implicitAssemblies = new ArrayList(); this.implicitAssemblies = implicitAssemblies; } implicitAssemblies.Add(reference2.Assembly); } } catch (JSVsaException) { } } } }