示例#1
0
文件: VsaItems.cs 项目: raj581/Marvin
        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);
        }
示例#2
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;
        }