public void DuplicateStackedNodes(INodeModel copiedNode, Dictionary <INodeModel, NodeModel> mapping, Vector2 delta, int stackInsertionIndex, List <StackedNodesStruct> implicitStackedNodes, StackBaseModel pastedStackModel)
        {
            pastedStackModel.ClearNodes();

            if (implicitStackedNodes?.Count > 0)
            {
                foreach (var stackedNodeStruct in implicitStackedNodes)
                {
                    DuplicateNode(stackedNodeStruct.stackedNodeModel, mapping,
                                  pastedStackModel, delta, stackInsertionIndex != -1 ? stackInsertionIndex++ : -1);
                }
            }
        }
Ejemplo n.º 2
0
        public void DuplicateStackedNodes(INodeModel copiedNode, Dictionary <INodeModel, NodeModel> mapping, Vector2 delta, int stackInsertionIndex, List <StackedNodesStruct> implicitStackedNodes, StackBaseModel pastedStackModel)
        {
            pastedStackModel.ClearNodes();

            if (implicitStackedNodes?.Count > 0)
            {
                foreach (var stackedNodeStruct in implicitStackedNodes)
                {
                    DuplicateNode(stackedNodeStruct.stackedNodeModel, mapping,
                                  pastedStackModel, delta, stackInsertionIndex != -1 ? stackInsertionIndex++ : -1);
                }
            }

            if (copiedNode is FunctionModel copiedFunctionModel && pastedStackModel is FunctionModel pastedFunctionModel)
            {
                pastedFunctionModel.ClearVariableDeclarations();
                foreach (IVariableDeclarationModel functionVariableModel in copiedFunctionModel.FunctionVariableModels)
                {
                    VariableDeclarationModel variableDeclaration = ((VariableDeclarationModel)functionVariableModel).Clone();

                    // Reset name to be the exact same as the original since they are in different scopes
                    variableDeclaration.Name  = functionVariableModel.Name;
                    variableDeclaration.Owner = pastedFunctionModel;
                    pastedFunctionModel.VariableDeclarations.Add(variableDeclaration);
                }

                pastedFunctionModel.ClearParameterDeclarations();
                foreach (IVariableDeclarationModel functionParameterModel in copiedFunctionModel.FunctionParameterModels)
                {
                    VariableDeclarationModel parameterDeclaration = ((VariableDeclarationModel)functionParameterModel).Clone();

                    // Reset name to be the exact same as the original since they are in different scopes
                    parameterDeclaration.Name  = functionParameterModel.Name;
                    parameterDeclaration.Owner = pastedFunctionModel;
                    pastedFunctionModel.FunctionParameters.Add(parameterDeclaration);
                }
            }
        }