Created
November 2, 2019 09:59
-
-
Save sfmskywalker/c3d764724a42a004a1f23d8966d72668 to your computer and use it in GitHub Desktop.
LiquidConfigurationHandler.cs - Building Workflow Driven .NET Core Applications with Elsa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Threading; | |
using System.Threading.Tasks; | |
using Elsa.Samples.UserRegistration.Web.Models; | |
using Elsa.Scripting.Liquid.Messages; | |
using Fluid; | |
using MediatR; | |
namespace Elsa.Samples.UserRegistration.Web.Handlers | |
{ | |
/// <summary> | |
/// Configure the Liquid template context to allow access to certain models. | |
/// </summary> | |
public class LiquidConfigurationHandler : INotificationHandler<EvaluatingLiquidExpression> | |
{ | |
public Task Handle(EvaluatingLiquidExpression notification, CancellationToken cancellationToken) | |
{ | |
var context = notification.TemplateContext; | |
context.MemberAccessStrategy.Register<User>(); | |
context.MemberAccessStrategy.Register<RegistrationModel>(); | |
return Task.CompletedTask; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment