示例#1
0
        protected override void UpdateInternal()
        {
            base.UpdateInternal();
            FieldLabel nameField = this.GetNameField();

            if (mProcedure != null && nameField != null)
            {
                nameField.SetValue(mProcedure.Name);
            }
        }
示例#2
0
        /// Sets the mutator name, including setting the associated name field on the block.
        /// </summary>
        protected override void SetProcedureNameInternal(string name)
        {
            mProcedure = mProcedure.CloneWithName(name);
            FieldLabel nameField = GetNameField();

            if (nameField != null)
            {
                nameField.SetValue(name);
            }
        }
示例#3
0
        /// <summary>
        /// Called when the mutator is attached to a block. It will make sure the procedure name on the
        /// block's name field is in sync with the mutator's Procedure Info, and register a listener on the name field for future edits.
        /// </summary>
        protected override void OnAttached()
        {
            string procedureName = null;

            // Update the Procedure Info with procedure name from NAME field.
            // In the case of this class, this will not update the mutation serialization,
            // but initializes the value to synch with caller's Procedure Info.
            FieldLabel nameField = GetNameField();

            if (nameField != null)
            {
                string blockProcName = nameField.GetValue();
                string infoProcName  = (mProcedure == null) ? null : mProcedure.Name;
                if (!string.IsNullOrEmpty(blockProcName) && !blockProcName.Equals(infoProcName))
                {
                    if (!string.IsNullOrEmpty(infoProcName))
                    {
                        throw new Exception("Attached to block that already has a differing procedure name.");
                    }
                    procedureName = blockProcName;
                }
                else
                {
                    procedureName = infoProcName;
                }
            }
            mProcedure = mProcedure == null
                        ? new Procedure(procedureName, new List <string>(), ProcedureDB.HAS_STATEMENTS_DEFAULT)
                        : new Procedure(procedureName, mProcedure.Arguments, mProcedure.DefinitionHasStatementBody);

            base.OnAttached();

            if (nameField != null)
            {
                nameField.SetValue(procedureName);
            }
        }