static State ConvertConstantNodesToVariableNodes(State previousState, ConvertConstantNodesToVariableNodesAction action)
        {
            var graphModel = (VSGraphModel)previousState.CurrentGraphModel;

            foreach (var iConstantModel in action.ConstantModels)
            {
                var constantModel = (ConstantNodeModel)iConstantModel;

                var declarationModel = graphModel.CreateGraphVariableDeclaration(TypeSystem.CodifyString(constantModel.Type.FriendlyName()), constantModel.Type.GenerateTypeHandle(graphModel.Stencil), true);
                declarationModel.UseDeclarationModelCopy(constantModel);
                var variableModel = graphModel.CreateVariableNode(declarationModel, constantModel.Position);

                foreach (var edge in graphModel.GetEdgesConnections(constantModel.OutputPort).ToList())
                {
                    graphModel.CreateEdge(edge.InputPortModel, variableModel.OutputPort);
                    graphModel.DeleteEdge(edge);
                }

                graphModel.DeleteNode(constantModel, GraphModel.DeleteConnections.False);
            }

            return(previousState);
        }
Ejemplo n.º 2
0
 public void CodifyNameTest(string actual, string expected)
 {
     Assert.That(TypeSystem.CodifyString(actual), Is.EqualTo(expected));
 }