Пример #1
0
 /// <summary>
 /// Notification that a variable is renaming.
 /// If the name matches one of this block's variables,rename it.
 /// </summary>
 /// <param name="oldName"> Previous name of variable</param>
 /// <param name="newName"> Renamed Variable.</param>
 public void RenameVar(string oldName, string newName)
 {
     foreach (var input in InputList)
     {
         foreach (var field in input.FieldRow)
         {
             if (field is FieldVariable && Names.Equals(oldName, field.GetValue()))
             {
                 field.SetValue(newName);
             }
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Find the variable by the given name and return it.Return null if it is not
 ///     found.
 /// </summary>
 /// <param name="name"> The name to check for.</param>
 /// <returns> The variable with the given name, or null if it was not found.</returns>
 public VariableModel GetVariable(string name)
 {
     foreach (var key in mVariableMap.Keys)
     {
         foreach (var variable in mVariableMap[key])
         {
             if (Names.Equals(variable.Name, name))
             {
                 return(variable);
             }
         }
     }
     return(null);
 }
Пример #3
0
        /// <summary>
        /// Find all the uses of a named variable.
        /// </summary>
        /// <param name="name"> Name of variable.</param>
        /// <returns> Array of block usages.</returns>
        public List <Block> GetVariableUses(string name)
        {
            var uses   = new List <Block>();
            var blocks = this.GetAllBlocks();

            // Iterate through every block and check the name
            foreach (var block in blocks)
            {
                var blockVariables = block.GetVars();
                if (null != blockVariables && blockVariables.Count != 0)
                {
                    foreach (var varName in blockVariables)
                    {
                        // Variable name may be null if the block is only half-built.
                        if (null != varName && null != name && Names.Equals(varName, name))
                        {
                            uses.Add(block);
                        }
                    }
                }
            }
            return(uses);
        }