8000 Passing parameters to variable argument function · Issue #107 · mparlak/Flee · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Passing parameters to variable argument function #107
Open
@mercurial-moon

Description

@mercurial-moon

I have wrapper that creates list's of various types.

    public static class ListWrapper
    {
        public static List<string> CreateListStr(params string[] args)
        {
            return new List<string>(args);
        }
        public static List<int> CreateListInt(params int[] args)
        {
            return new List<int>(args);
        }
        public static List<object> CreateListObj(params object[] args)
        {
            return new List<object>(args);
        }
    }

I then try to use it like this.

            ExpressionContext context = new ExpressionContext();
            context.Imports.AddType(typeof(ListWrapper), "ExpressionEngineTests");
            context.Variables["liststr"] = new string[1];
            context.Variables["listint"] = new int[1];
            context.Variables["listobj"] = new object[1];

            var dynExpStr = context.CompileDynamic("CreateListStr(liststr)"); // <- Error: Flee.PublicTypes.ExpressionCompileException: 'FunctionCallElement: Could find not function 'CreateListStr(String[])''
            var dynExpInt = context.CompileDynamic("CreateListInt(listint)");
            var dynExpObj = context.CompileDynamic("CreateListObj(listobj)");

            context.Variables["liststr"] = "\"a\", \"b\", \"c\"";
            context.Variables["listint"] = "1, 2, 3";
            context.Variables["listobj"] = "\"a\", 1, true";

            var res1 = dynExpStr.Evaluate();
            var res2 = dynExpInt.Evaluate();
            var res3 = dynExpObj.Evaluate();

However I get error at the indicated line
Flee.PublicTypes.ExpressionCompileException: 'FunctionCallElement: Could find not function 'CreateListStr(String[])''

Is there any other syntax for getting this done?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0