Inheritance: IVsaItem
Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
 public void Remove(int itemIndex)
 {
     if (this.isClosed)
     {
         throw new JSVsaException(JSVsaError.EngineClosed);
     }
     this.TryObtainLock();
     try
     {
         if ((0 > itemIndex) || (itemIndex >= this.items.Count))
         {
             throw new JSVsaException(JSVsaError.ItemNotFound);
         }
         VsaItem item = (VsaItem)this.items[itemIndex];
         item.Remove();
         this.items.RemoveAt(itemIndex);
         if (item is VsaStaticCode)
         {
             this.staticCodeBlockCount--;
         }
     }
     finally
     {
         this.ReleaseLock();
     }
 }
 public virtual IVsaItem GetItem(string itemName)
 {
     for (int i = 0, n = this.items.Count; i < n; i++)
     {
         VsaItem item = (VsaItem)this.items[i];
         if (null == item.Name && null == itemName || null != item.Name && item.Name.Equals(itemName))
         {
             return((IVsaItem)this.items[i]);
         }
     }
     return(null);
 }
 internal DocumentContext(String documentName, int startLine, int startCol, int lastLineInSource, VsaItem sourceItem){
   this.documentName = documentName;
   this.documentWriter = null;
   this.startLine = startLine;
   this.startCol = startCol;
   this.lastLineInSource = lastLineInSource;
   this.sourceItem = sourceItem;
   this.engine = sourceItem.engine;
   this.debugOn = null == engine ? false : engine.GenerateDebugInfo;
   this._compilerGlobals = null;
   this.checkForFirst = false;
 }
        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);
        }
 internal DocumentContext(String documentName, int startLine, int startCol, int lastLineInSource, VsaItem sourceItem)
 {
     this.documentName     = documentName;
     this.documentWriter   = null;
     this.startLine        = startLine;
     this.startCol         = startCol;
     this.lastLineInSource = lastLineInSource;
     this.sourceItem       = sourceItem;
     this.engine           = sourceItem.engine;
     this.debugOn          = null == engine ? false : engine.GenerateDebugInfo;
     this._compilerGlobals = null;
     this.checkForFirst    = false;
 }
 internal DocumentContext(String name, VsaEngine engine){
   this.documentName = name;
   this.documentWriter = null;
   this.startLine = 0;
   this.startCol = 0;
   this.lastLineInSource = 0;
   this.sourceItem = null;
   this.engine = engine;
   this.debugOn = null == engine ? false : engine.GenerateDebugInfo;
   this._compilerGlobals = null;
   this.reportedVariables = null;
   this.checkForFirst = false;
 }
 internal DocumentContext(String name, VsaEngine engine)
 {
     this.documentName      = name;
     this.documentWriter    = null;
     this.startLine         = 0;
     this.startCol          = 0;
     this.lastLineInSource  = 0;
     this.sourceItem        = null;
     this.engine            = engine;
     this.debugOn           = null == engine ? false : engine.GenerateDebugInfo;
     this._compilerGlobals  = null;
     this.reportedVariables = null;
     this.checkForFirst     = false;
 }
 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);
 }
 public virtual void RemoveItem(string itemName)
 {
     for (int i = 0, n = this.items.Count; i < n; i++)
     {
         VsaItem item = (VsaItem)this.items[i];
         if (null == item.Name && null == itemName || null != item.Name && item.Name.Equals(itemName))
         {
             item.Remove();
             this.items.Remove(i);
             return;
         }
     }
     throw new VsaException(VsaError.ItemNotFound);
 }
Ejemplo n.º 11
0
        public virtual IJSVsaItem GetItem(string itemName)
        {
            int num   = 0;
            int count = this.items.Count;

            while (num < count)
            {
                VsaItem item = (VsaItem)this.items[num];
                if (((item.Name == null) && (itemName == null)) || ((item.Name != null) && item.Name.Equals(itemName)))
                {
                    return((IJSVsaItem)this.items[num]);
                }
                num++;
            }
            return(null);
        }
 internal DocumentContext(VsaItem sourceItem){
   if (sourceItem.codebase != null)
     this.documentName = sourceItem.codebase;
   else{
     string rootMoniker = sourceItem.engine.RootMoniker;
     this.documentName = rootMoniker + (rootMoniker.EndsWith("/", StringComparison.Ordinal) ? "" : "/") + sourceItem.Name;
   }
   this.documentWriter = null;
   this.startLine = 0;
   this.startCol = 0;
   this.lastLineInSource = 0;
   this.sourceItem = sourceItem;
   this.engine = sourceItem.engine;
   this.debugOn = null == engine ? false : engine.GenerateDebugInfo;
   this._compilerGlobals = null;
   this.checkForFirst = false;
 }
Ejemplo n.º 13
0
        public virtual void RemoveItem(string itemName)
        {
            int num   = 0;
            int count = this.items.Count;

            while (num < count)
            {
                VsaItem item = (VsaItem)this.items[num];
                if (((item.Name == null) && (itemName == null)) || ((item.Name != null) && item.Name.Equals(itemName)))
                {
                    item.Remove();
                    this.items.Remove(num);
                    return;
                }
                num++;
            }
            throw new JSVsaException(JSVsaError.ItemNotFound);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
 public virtual void Remove(int index)
 {
     lock (this)
     {
         CheckForClosed();
         if (index >= 0 && index < itemList.Count)
         {
             VsaItem item = (VsaItem)(itemList[index]);
             item.RemovingItem();
             itemList.RemoveAt(index);
             engine.IsDirty = true;
         }
         else
         {
             throw new VsaException(VsaError.ItemNotFound);
         }
     }
 }
 internal DocumentContext(VsaItem sourceItem)
 {
     if (sourceItem.codebase != null)
     {
         this.documentName = sourceItem.codebase;
     }
     else
     {
         string rootMoniker = sourceItem.engine.RootMoniker;
         this.documentName = rootMoniker + (rootMoniker.EndsWith("/", StringComparison.Ordinal) ? "" : "/") + sourceItem.Name;
     }
     this.documentWriter   = null;
     this.startLine        = 0;
     this.startCol         = 0;
     this.lastLineInSource = 0;
     this.sourceItem       = sourceItem;
     this.engine           = sourceItem.engine;
     this.debugOn          = null == engine ? false : engine.GenerateDebugInfo;
     this._compilerGlobals = null;
     this.checkForFirst    = false;
 }
Ejemplo n.º 17
0
 public virtual void Remove(int itemIndex)
 {
     if (this.isClosed)
     {
         throw new VsaException(VsaError.EngineClosed);
     }
     this.TryObtainLock();
     try{
         if (0 <= itemIndex && itemIndex < items.Count)
         {
             VsaItem item = (VsaItem)this.items[itemIndex];
             item.Remove();
             this.items.RemoveAt(itemIndex);
             if (item is VsaStaticCode)
             {
                 this.staticCodeBlockCount--;
             }
             return;
         }
         throw new VsaException(VsaError.ItemNotFound);
     }finally{
         this.ReleaseLock();
     }
 }
Ejemplo n.º 18
0
        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);
        }