Skip to content

add JUSTContext.RegisterCustomFunction(string methodAlias, Delegate method) #318

@naratteu

Description

@naratteu

I'm using the following code instead of RegisterCustomFunction to leverage JUST.net in a C# REPL environment.

#r "nuget: JUST.net, 4.4.1"
using JUST;
using System.Reflection;
var context = new JUSTContext();
var dict = typeof(JUSTContext).GetField("_customFunctions", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(context) as Dictionary<string, MethodInfo>;
var func = () => "Hello";
dict["custom"] = func.Method;
new JsonTransformer(context).Transform("""{a:"#custom()"}""", "") // {"a":"Hello"}

I don't want there to be a dynamic loading from the file system when adding custom functions.

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