Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liquid Expression usage in console app #6352

Open
jskumar opened this issue Jan 29, 2025 · 0 comments
Open

Liquid Expression usage in console app #6352

jskumar opened this issue Jan 29, 2025 · 0 comments

Comments

@jskumar
Copy link

jskumar commented Jan 29, 2025

In console app, Liquid Expressions is not working as expected but CSharp Expressions works. Could you please review and help me to handle this.

@cvijayak Thanks.

 ```
var host = Host.CreateDefaultBuilder()
.ConfigureServices((context, services) =>
{
services.AddMediator();
services.AddElsa(elsa => {
elsa.UseCSharp();
elsa.UseLiquid();
});
services.AddHostedService();
})
.Build();
await host.RunAsync();


using (var scope = _serviceProvider.CreateScope())
{
var evaluator = scope.ServiceProvider.GetRequiredService();

var executionContext = new ExpressionExecutionContext(scope.ServiceProvider, new MemoryRegister());
executionContext.SetVariable("Name", "Context World");

string e1 = "DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")";
var r1 = await evaluator.EvaluateAsync(new Expression("CSharp", e1), executionContext);
Console.WriteLine(r1);

string e3 = ""Hello, " + Variable.Name";
var r3 = await evaluator.EvaluateAsync(new Expression("CSharp", e3), executionContext);
Console.WriteLine(r3); // Hello, Context World

string e4 = "Hello {{ Variables.Name }}";
var r4 = await evaluator.EvaluateAsync(new Expression("Liquid", e4), executionContext);
Console.WriteLine(r4);

}


Thanks again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant