Пример #1
0
 public virtual void Remove(string itemName)
 {
     if (this.isClosed)
     {
         throw new VsaException(VsaError.EngineClosed);
     }
     this.TryObtainLock();
     try{
         if (itemName == null)
         {
             throw new System.ArgumentNullException();
         }
         for (int i = 0, n = this.items.Count; i < n; i++)
         {
             IVsaItem item = (IVsaItem)this.items[i];
             if (item.Name.Equals(itemName))
             {
                 ((VsaItem)item).Remove();
                 this.items.RemoveAt(i);
                 ((VsaEngine)this.engine).IsDirty = true;
                 if (item is VsaStaticCode)
                 {
                     this.staticCodeBlockCount--;
                 }
                 return;
             }
         }
         throw new VsaException(VsaError.ItemNotFound);
     }finally{
         this.ReleaseLock();
     }
 }
 public virtual void RemoveItem(IVsaItem item)
 {
     for (int i = 0, n = this.items.Count; i < n; i++)
     {
         VsaItem vsaItem = (VsaItem)this.items[i];
         if (vsaItem == item)
         {
             vsaItem.Remove();
             this.items.Remove(i);
             return;
         }
     }
     throw new VsaException(VsaError.ItemNotFound);
 }
Пример #3
0
        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);
        }
Пример #4
0
 public IVsaItem this[string itemName] {
     get{
         if (this.isClosed)
         {
             throw new VsaException(VsaError.EngineClosed);
         }
         if (itemName != null)
         {
             for (int i = 0, n = this.items.Count; i < n; i++)
             {
                 IVsaItem item = (IVsaItem)this.items[i];
                 if (item.Name.Equals(itemName))
                 {
                     return(item);
                 }
             }
         }
         throw new VsaException(VsaError.ItemNotFound);
     }
 }
Пример #5
0
 public IVsaItem this[string itemName] {
     [PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
     get{
         if (this.isClosed)
         {
             throw new VsaException(VsaError.EngineClosed);
         }
         if (itemName != null)
         {
             for (int i = 0, n = this.items.Count; i < n; i++)
             {
                 IVsaItem item = (IVsaItem)this.items[i];
                 if (item.Name.Equals(itemName))
                 {
                     return(item);
                 }
             }
         }
         throw new VsaException(VsaError.ItemNotFound);
     }
 }
Пример #6
0
 public virtual bool Compile()
 {
     this.TryObtainLock();
     try{
         Preconditions(Pre.EngineNotClosed |
                       Pre.EngineNotRunning |
                       Pre.EngineInitialised |
                       Pre.RootNamespaceSet);
         // look through items for at least one code item
         bool haveCode = false;
         for (int i = 0, n = this.vsaItems.Count; !haveCode && i < n; ++i)
         {
             IVsaItem item = vsaItems[i];
             haveCode = this.vsaItems[i].ItemType == VsaItemType.Code;
         }
         if (!haveCode)
         {
             throw Error(VsaError.EngineEmpty);
         }
         try{
             this.ResetCompiledState();
             this.isEngineCompiled = DoCompile();
         }catch (VsaException) {
             throw;
         }catch (Exception e) {
             throw new VsaException(VsaError.InternalCompilerError, e.ToString(), e);
         }catch {
             throw new VsaException(VsaError.InternalCompilerError);
         }
         if (this.isEngineCompiled)
         {
             this.haveCompiledState     = true;
             this.failedCompilation     = false;
             this.compiledRootNamespace = this.rootNamespace;
         }
         return(this.isEngineCompiled);
     }finally{
         this.ReleaseLock();
     }
 }
Пример #7
0
        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();
            }
        }
Пример #8
0
 public void RemoveItem(IVsaItem item)
 {
     throw new NotImplementedException();
 }
Пример #9
0
 public void RemoveItem(IVsaItem item)
 {
     throw new NotImplementedException ();
 }
 public virtual void RemoveItem(IVsaItem item){
   for (int i = 0, n = this.items.Count; i < n; i++){
     VsaItem vsaItem = (VsaItem)this.items[i];
     if (vsaItem == item){
       vsaItem.Remove();
       this.items.Remove(i);
       return;
     }
   }
   throw new VsaException(VsaError.ItemNotFound);
 }
Пример #11
0
 public CodeBase(String name, IVsaItem item, IVsaSite site)
 {
     this.name = name;
     this.item = item;
     this.site = site;
 }
Пример #12
0
 // Constructor.
 public CodeBase(String name, IVsaItem item)
 {
     this.name = name;
     this.item = item;
     this.site = null;
 }
Пример #13
0
	public CodeBase(String name, IVsaItem item, IVsaSite site)
			{
				this.name = name;
				this.item = item;
				this.site = site;
			}
Пример #14
0
	// Constructor.
	public CodeBase(String name, IVsaItem item)
			{
				this.name = name;
				this.item = item;
				this.site = null;
			}
Пример #15
0
 public VsaItemAlreadyExistsException(IVsaItem item, string itemName)
     : base(string.Format("An item with the name '{0}' already exists.", itemName))
 {
     _item = item;
 }