private static bool IsSelfCalling(string functionName, BaseRuntimeTreeNode runtimeTreeNode)
        {
            if (runtimeTreeNode is FunctionParameterRuntimeTreeNode)
            {
                FunctionParameterRuntimeTreeNode functionParameterRuntimeTreeNode = runtimeTreeNode as FunctionParameterRuntimeTreeNode;

                if (functionParameterRuntimeTreeNode.GetHostedFunction().GetCompositeName() == functionName)
                {
                    return(true);
                }
                return(IsSelfCalling(functionName, functionParameterRuntimeTreeNode.GetHostedFunction()));
            }

            if (runtimeTreeNode is BaseFunctionRuntimeTreeNode)
            {
                BaseFunctionRuntimeTreeNode functionRuntimeTreeNode = runtimeTreeNode as BaseFunctionRuntimeTreeNode;

                if (functionName == functionRuntimeTreeNode.GetCompositeName())
                {
                    return(true);
                }

                foreach (BaseParameterRuntimeTreeNode parameterRuntimeTreeNode in functionRuntimeTreeNode.Parameters)
                {
                    if (IsSelfCalling(functionName, parameterRuntimeTreeNode))
                    {
                        return(true);
                    }
                }

                return(false);
            }

            return(false);
        }
示例#2
0
    private void BtnInputParameterClicked(XElement functionNode, XElement parameterNode, string parameterName)
    {
        if (parameterNode != null)
        {
            parameterNode.Remove();
        }

        // Adding function call - GetInputParameter(InputParameterName = "...")

        IFunction getInputParameterFunc = FunctionFacade.GetFunction(GetInputParameterFunctionName);

        IMetaFunction function = TreeHelper.GetFunction(functionNode);
        ParameterProfile parameterProfile = function.ParameterProfiles.FirstOrDefault(p => p.Name == parameterName);
        var selectedParameter = _state.Parameters.First(ip => InputParameterCanBeAssigned(parameterProfile.Type, ip.Type));
        string selectedParameterName = selectedParameter != null ? selectedParameter.Name : string.Empty;

        var newElement = new FunctionParameterRuntimeTreeNode(parameterName, new FunctionRuntimeTreeNode(getInputParameterFunc)).Serialize();
        functionNode.Add(newElement);

        var inputParameterNameNode = new ConstantObjectParameterRuntimeTreeNode(GetInputParameterFunctionParameterName, selectedParameterName).Serialize();
        newElement.Elements().First().Add(inputParameterNameNode);

        SaveChanges();
    }