예제 #1
0
        /// <summary>
        /// Class for one block.
        /// Not normally called directly,workspace.newBlock() is preferred.
        /// </summary>
        /// <param name="workspace"> The Block's workspace</param>
        /// <param name="prototypeName"> Name of the language object containing
        /// type-specific functions for this block. </param>
        /// <param name="opt_id">Use this ID if provided,otherwise create a new id</param>
        public Block(Workspace workspace, string prototypeName = null, string opt_id = null)
        {
            Type = prototypeName;
            ID   = !string.IsNullOrEmpty(opt_id) && workspace.GetBlockById(opt_id) == null
                  ? opt_id
                  : Utils.GenUid();

            workspace.BlockDB.Add(ID, this);
            Workspace = workspace;

            OutputConnection   = null;
            NextConnection     = null;
            PreviousConnection = null;
            InputList          = new List <Input>();

            workspace.AddTopBlock(this);
        }