public virtual IVsaItem CreateItem (String name, VsaItemType itemType, VsaItemFlag itemFlag) { lock (this) { CheckForClosed(); if (engine.IsRunning) { throw new VsaException(VsaError.EngineRunning); } if (itemType != VsaItemType.Code) { // We only support code items in this implementation. throw new VsaException(VsaError.ItemTypeNotSupported); } if (itemFlag == VsaItemFlag.Class) { // We don't support class flags. throw new VsaException(VsaError.ItemFlagNotSupported); } VsaItem.ValidateName(engine, name); VsaItem item = new VsaCodeItem(engine, name, itemFlag); itemList.Add(item); return(item); } }
internal VsaItem(VsaEngine engine, string name, VsaItemType type, VsaItemFlag flag) { this.engine = engine; this.name = name; this.type = type; this.flag = flag; }
internal VsaItem(VsaEngine engine, string itemName, VsaItemType type, VsaItemFlag flag){ this.engine = engine; this.type = type; this.name = itemName; this.flag = flag; this.codebase = null; this.isDirty = true; }
internal VsaItem(VsaEngine engine, string itemName, VsaItemType type, VsaItemFlag flag) { this.engine = engine; this.type = type; this.name = itemName; this.flag = flag; this.codebase = null; this.isDirty = true; }
// Constructor. internal VsaItem(VsaEngine engine, String name, VsaItemType type, VsaItemFlag flag) { this.engine = engine; this.codebaseOption = null; this.isDirty = false; this.type = type; this.name = name; this.flag = flag; }
public virtual IVsaItem CreateDynamicItem(string itemName, VsaItemType type) { if (this.engine.IsRunning) { return(AddItem(itemName, type)); } else { throw new VsaException(VsaError.EngineNotRunning); } }
internal VsaHostObject(VsaEngine engine, string itemName, VsaItemType type, VsaScriptScope scope) : base(engine, itemName, type, VsaItemFlag.None){ this.hostObject = null; this.exposeMembers = false; this.isVisible = false; this.exposed = false; this.compiled = false; this.scope = scope; // non-null only when the VsaHostObject is added to a VsaScriptScope (rather than being added directly to the engine) this.field = null; this.typeString = "System.Object"; }
internal VsaHostObject(VsaEngine engine, string itemName, VsaItemType type, VsaScriptScope scope) : base(engine, itemName, type, VsaItemFlag.None) { this.hostObject = null; this.exposeMembers = false; this.isVisible = false; this.exposed = false; this.compiled = false; this.scope = scope; // non-null only when the VsaHostObject is added to a VsaScriptScope (rather than being added directly to the engine) this.field = null; this.typeString = "System.Object"; }
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 CreateItem(string name, VsaItemType itemType, VsaItemFlag itemFlag) { if (names.Contains(name)) { throw new VsaException(VsaError.ItemNameInUse); } IVsaItem item = null; switch (itemType) { case VsaItemType.AppGlobal: if (itemFlag != VsaItemFlag.None) { throw new VsaException(VsaError.ItemFlagNotSupported); } item = new VsaGlobalItem(engine, name, itemFlag); break; case VsaItemType.Code: item = new VsaCodeItem(engine, name, itemFlag); break; case VsaItemType.Reference: if (itemFlag != VsaItemFlag.None) { throw new VsaException(VsaError.ItemFlagNotSupported); } item = new VsaReferenceItem(engine, name, itemFlag); break; } if (item != null) { items.Add(item); names.Add(name); } engine.IsDirty = true; return(item); }
public void ItemTypeOnEngineClosed() { VsaEngine engine = new VsaEngine(); IVsaItems items; IVsaItem item; engine.RootMoniker = "foo://nowhere/path"; engine.Site = new Site(); engine.InitNew(); items = engine.Items; item = items.CreateItem("item1", VsaItemType.Reference, VsaItemFlag.None); engine.Close(); try { VsaItemType type = item.ItemType; } catch (VsaException e) { Assert.AreEqual(VsaError.EngineClosed, e.ErrorCode, "#5"); } }
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 CreateItem(string name, VsaItemType itemType, VsaItemFlag itemFlag) { if (names.Contains (name)) throw new VsaException (VsaError.ItemNameInUse); IVsaItem item = null; switch (itemType) { case VsaItemType.AppGlobal: if (itemFlag != VsaItemFlag.None) throw new VsaException (VsaError.ItemFlagNotSupported); item = new VsaGlobalItem (engine, name, itemFlag); break; case VsaItemType.Code: item = new VsaCodeItem (engine, name, itemFlag); break; case VsaItemType.Reference: if (itemFlag != VsaItemFlag.None) throw new VsaException (VsaError.ItemFlagNotSupported); item = new VsaReferenceItem (engine, name, itemFlag); break; } if (item != null) { items.Add (item); names.Add (name); } engine.IsDirty = true; return item; }
internal VsaHostObject(VsaEngine engine, string itemName, VsaItemType type) : this(engine, itemName, type, null) { }
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) { lock(this) { CheckForClosed(); if(engine.IsRunning) { throw new VsaException(VsaError.EngineRunning); } if(itemType != VsaItemType.Code) { // We only support code items in this implementation. throw new VsaException(VsaError.ItemTypeNotSupported); } if(itemFlag == VsaItemFlag.Class) { // We don't support class flags. throw new VsaException(VsaError.ItemFlagNotSupported); } VsaItem.ValidateName(engine, name); VsaItem item = new VsaCodeItem(engine, name, itemFlag); itemList.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 CreateDynamicItem(string itemName, VsaItemType type){ if (this.engine.IsRunning) return AddItem(itemName, type); else throw new VsaException(VsaError.EngineNotRunning); }
public IVsaItem AddItem(string item_name, VsaItemType type) { throw new NotImplementedException(); }
public IVsaItem CreateDynamicItem(string item_name, VsaItemType type) { throw new NotImplementedException (); }
internal VsaHostObject(VsaEngine engine, string itemName, VsaItemType type) : this(engine, itemName, type, null){ }