示例#1
0
        public override void Process()
        {
            List<string> tokens = Helper.ExtractTokens(processedContents, " ", ":");

            blockId = tokens[1];
            handle = new BlockHandle(tokens[2].Replace(";", ""));

            base.Process();
        }
示例#2
0
        public override void Attach(TreeNode myNode)
        {
            myNode.Tag = this;
            myNode.SelectedImageKey = myNode.ImageKey = "Block";

            if ( info == null ) info = myWeb.GetBlockHandle(myId);

            myNode.Text = myId + "<" + info.ToString() + ">";

            addTempNode(myNode);
            myNodes.Add(myNode);
        }
示例#3
0
        public IContainedBlock LoadBlock(BlockHandle handle, params object[] args)
        {
            if (!blocks.ContainsKey(handle) )
            {
                if (failover != null)
                {
                    return failover.LoadBlock(handle);
                }

                return null;
            }

            DBDefinition block = blocks[handle];

            return new DynamicBlock(block, args);
        }
示例#4
0
        public override void Execute()
        {
            BlockHandle handle = new BlockHandle(id.ValueText);
            DBDefinition definition = new DBDefinition();

            foreach (DefBlockBodyItem bodyItem in body)
            {
                bodyItem.Fill(definition);
            }

            if (baseType.Handle != null)
            {
                definition.BaseType = baseType.Handle;
            }

            //register the dynamic block so in future commands
            //user can instantiate it using: block command
            ExecutionContext.Current.RegisterDynamicBlock(handle, definition);
        }
示例#5
0
        public static BlockHandle ReadBlockHandle(XmlElement myElement)
        {
            if (!myElement.HasAttribute("className")) return null;

            BlockHandle result = new BlockHandle();

            result.ClassName = myElement.GetAttribute("className");

            if (myElement.HasAttribute("version"))
            {
                result.BlockVersion = new BlockVersion(myElement.GetAttribute("version"));
            }

            if (myElement.HasAttribute("product"))
            {
                result.Product = myElement.GetAttribute("product");
            }

            return result;
        }
示例#6
0
 public void InitFrom(BlockHandle v)
 {
     ClassName = v.ClassName;
     BlockVersion = v.BlockVersion;
     Product = v.Product;
 }
示例#7
0
        public static BlockHandle Parse(string txt)
        {
            BlockHandle result = new BlockHandle();

            //txt is generated using CID.ToString
            //this.Product + "." + this.Identifier + "(v" + this.BlockVersion.ToString(4) + ")";
            int idx1 = txt.IndexOf(".");
            int idx2 = txt.IndexOf("(v", idx1 + 1);

            bool hasProduct = (idx1 != -1 || (idx2 != -1 && idx1 < idx2));
            bool hasVersion = (idx2 != -1);

            if (idx2 == -1) idx2 = txt.Length;

            if (hasProduct)
            {
                result.Product = txt.Substring(0, idx1);
            }

            result.ClassName = txt.Substring(idx1 + 1, idx2 - idx1 - 1);

            if (hasVersion)
            {
                string version = txt.Substring(idx2 + 2);
                version = version.Replace(")", "");
                result.BlockVersion = new BlockVersion(version);
            }

            return result;
        }
示例#8
0
        public static BlockHandle New(string clsName, string product)
        {
            BlockHandle result = new BlockHandle(clsName, product);

            return result;
        }
示例#9
0
        public static BlockHandle New(string clsName)
        {
            BlockHandle result = new BlockHandle();
            result.ClassName = clsName;

            return result;
        }
示例#10
0
 public BlockWebSysEventArgs(IBlockWeb web, string id)
 {
     BlockWeb = web;
     BlockHandle = new BlockHandle();
     BlockId = id;
 }
示例#11
0
 public BlockHandleAttribute(string clsName, string product)
 {
     id = new BlockHandle(clsName, product);
 }
示例#12
0
        public string AddBlock(BlockHandle handle, string identifier)
        {
            List<object> result = peerManager.SendMessage(peerId, MsgCode.CallBlockWebMethod, "AddBlock", handle, identifier);

            if (result == null) return null;

            return (string)result[0];
        }
示例#13
0
 public BlockWebSysEventArgs(IBlockWeb web, BlockHandle handle)
 {
     BlockWeb = web;
     BlockHandle = handle;
 }
示例#14
0
 public void AddBlock(BlockHandle handle, DBDefinition blockDef)
 {
     blocks[handle] = blockDef;
 }
示例#15
0
        public void RegisterDynamicBlock(BlockHandle handle, DBDefinition def)
        {
            if (parent != null)
            {
                //brokers are only kept at root level context
                parent.RegisterDynamicBlock(handle, def);
            }

            dynamicBlockBroker.AddBlock(handle, def);
        }
示例#16
0
        /// <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;
        }
示例#17
0
 public BlockHandleAttribute(string clsName, string product, int major, int minor, int build, int revision)
 {
     id = new BlockHandle(clsName, new BlockVersion(major, minor, build, revision), product);
 }
示例#18
0
 /// <summary>
 /// Returns true if given Block identifier 'c' has the same product and Id as this Block
 /// And their version is compatible
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 public bool IsCompatible(BlockHandle c)
 {
     return (ClassName == c.ClassName &&
         Product == c.Product &&
         BlockVersion.IsCompatible(c.BlockVersion));
 }
示例#19
0
        /// <summary>
        /// Loads a block with given identity information.
        /// </summary>
        /// <param name="handle"></param>
        /// <returns></returns>
        public IContainedBlock LoadBlock(BlockHandle handle, params object[] args)
        {
            List<BlockHandle> blocks = Blocks;
            IContainedBlock result = null;

            if (cidInfo.ContainsKey(handle))
            {
                string data = (string)cidInfo[handle];
                string assemblyName = data.Substring(0, data.IndexOf("\\"));
                string className = data.Substring(data.IndexOf("\\") + 1);

                //by default we suppose that className of the Block is the same as asembly name
                result = loader.LoadBlock(assemblyName, className, folder, args);
            }

            //TODO: lookup newer versions of this block in cidInfo

            if (result == null && failover != null)
            {
                return failover.LoadBlock(handle);
            }

            return result;
        }
示例#20
0
        public static BlockHandle New(string clsName, int major, int minor, int build, int revision, string product)
        {
            BlockHandle result = new BlockHandle(clsName, new BlockVersion(major, minor, build, revision), product);

            return result;
        }
示例#21
0
 public BlockHandleAttribute(string clsName)
 {
     id = new BlockHandle(clsName);
 }