コード例 #1
0
ファイル: BlockWeb.cs プロジェクト: mm-binary/DARF
        public virtual void DeleteBlock(string id)
        {
            logEvent(LogType.DeleteBlock, "DeleteBlock Begin - Handle: " + id.ToString());

            IContainedBlock comp = innerBlocks[id];

            BlockWebSysEventArgs eventArgs = new BlockWebSysEventArgs(this, id);
            bool hasCall = SysEventHelper.FireSysEvent(this, SysEventTiming.InsteadOf, SysEventCode.DeleteBlock, id, eventArgs);
            if (hasCall) return;

            SysEventHelper.FireSysEvent(this, SysEventTiming.Before, SysEventCode.DeleteBlock, id, eventArgs);

            comp.Dispose();
            innerBlocks.Remove(id);
            blockBroker.DisposeBlock(comp);

            SysEventHelper.FireSysEvent(this, SysEventTiming.After, SysEventCode.DeleteBlock, id, eventArgs);

            logEvent(LogType.DeleteBlock, "DeleteBlock Done - Handle: " + id.ToString());
        }
コード例 #2
0
ファイル: BlockWeb.cs プロジェクト: mm-binary/DARF
        /// <summary>
        /// Loads a block and adds it to the runtime blocks. CID is block definition and result string is an identifier
        /// to point to the runtime instance of the block.
        /// </summary>
        /// <param name="id">contains basic info (id, ver, prod) used to load the Block</param>
        /// input handle just</param>
        /// <returns>A handle to newly instantiated block</returns>
        /// 
        public virtual string AddBlock(BlockHandle handle, string identifier=null)
        {
            IContainedBlock comp = null;

            if (identifier == null)
            {
                identifier = Guid.NewGuid().ToString();
            }

            BlockWebSysEventArgs eventArgs = new BlockWebSysEventArgs(this, handle);

            SysEventHelper.FireSysEvent(this, SysEventTiming.Before, SysEventCode.LoadBlock, identifier, eventArgs);

            if (blockBroker != null)
            {
                comp = blockBroker.LoadBlock(handle, identifier, this);
            }

            logEvent(LogType.AddBlock, "Load done - Block: " + handle.ToString() + " with ID = " + identifier);
            SysEventHelper.FireSysEvent(this, SysEventTiming.After, SysEventCode.LoadBlock, identifier, eventArgs);

            bool doneCall = SysEventHelper.FireSysEvent(this, SysEventTiming.InsteadOf, SysEventCode.AddBlock, identifier, eventArgs);
            if (doneCall)
            {
                return identifier;
            }

            logEvent(LogType.AddBlock, "Adding - Block: " + handle.ToString() + " with ID = " + identifier);

            SysEventHelper.FireSysEvent(this, SysEventTiming.Before, SysEventCode.AddBlock, identifier, eventArgs);

            if (comp == null)
            {
                throw new System.Exception("Could not load the given handle: "+handle.ToString());
            }

            //TODO: check platform from attributes of the block
            initBlock(comp);

            logEvent(LogType.AddBlock, "Init Done - Block: " + handle.ToString() + " with ID = " + identifier);

            eventArgs.BlockId = identifier;
            SysEventHelper.FireSysEvent(this, SysEventTiming.After, SysEventCode.AddBlock, identifier, eventArgs);

            return identifier;
        }