Exemple #1
0
        public void Clear()
        {
            while (TopBlocks.Count > 0)
            {
                TopBlocks[TopBlocks.Count - 1].Dispose();
            }

            VariableMap.Clear();
            ConnectionDBList.Clear();
            ProcedureDB.Clear();
        }
Exemple #2
0
        /// <summary>
        /// Walk the workspace and update the map of variables to only contain ones in
        /// use on the workspace. Use when loading new workspaces from disk.
        /// </summary>
        /// <param name="clear"> True if the old variable map should be cleared.</param>
        public void UpdateVariableStore(bool clear = false, List <string> unitTestAllUsedVariable = null)
        {
            var variableNames = unitTestAllUsedVariable == null?Variables.AllUsedVariables(this) : unitTestAllUsedVariable;

            var varList = new List <JObject>();

            foreach (var name in variableNames)
            {
                // Get variable model with the used variable name.
                var tempVar = GetVariable(name);
                if (null != tempVar)
                {
                    JObject jsonData = new JObject();
                    jsonData["name"] = tempVar.Name;
                    jsonData["type"] = tempVar.Type;
                    jsonData["id"]   = tempVar.ID;
                    varList.Add(jsonData);
                }
                else
                {
                    JObject jsonData = new JObject();
                    jsonData["name"] = name;
                    jsonData["type"] = string.Empty;
                    jsonData["id"]   = string.Empty;
                    varList.Add(jsonData);
                    // instances are storing more than just name.
                }
            }

            if (clear)
            {
                VariableMap.Clear();
            }

            // Update the list in place so that the flyout's references stay correct.
            foreach (var varDict in varList)
            {
                if (null == this.GetVariable(varDict["name"].ToString()))
                {
                    this.CreateVariable(varDict["name"].ToString(), varDict["type"].ToString(), varDict["id"].ToString());
                }
            }
        }