@@ -36,15 +36,16 @@ public static class IWorkflowRuntimeContextExtensions
36
36
/// <param name="context">The current <see cref="IWorkflowRuntimeContext"/></param>
37
37
/// <param name="expressionObject">The object to evaluate</param>
38
38
/// <param name="data">The data to evaluate the object against</param>
39
+ /// <param name="authorization">The current <see cref="AuthorizationInfo"/>, if any</param>
39
40
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
40
41
/// <returns>The evaluated object</returns>
41
- public static async Task < object ? > EvaluateObjectAsync ( this IWorkflowRuntimeContext context , object expressionObject , object data , CancellationToken cancellationToken = default )
42
+ public static async Task < object ? > EvaluateObjectAsync ( this IWorkflowRuntimeContext context , object expressionObject , object data , AuthorizationInfo ? authorization , CancellationToken cancellationToken = default )
42
43
{
43
44
var json = JsonConvert . SerializeObject ( expressionObject , new JsonSerializerSettings ( ) { NullValueHandling = NullValueHandling . Ignore } ) ; ;
44
45
foreach ( var match in Regex . Matches ( json , @"""\$\{.+?\}""" , RegexOptions . Compiled ) . Cast < Match > ( ) )
45
46
{
46
47
var expression = Regex . Unescape ( match . Value [ 3 ..^ 2 ] . Trim ( ) . Replace ( @"\""" , @"""" ) ) ;
47
- var evaluationResult = await context . EvaluateAsync ( expression , data , cancellationToken ) ;
48
+ var evaluationResult = await context . EvaluateAsync ( expression , data , authorization , cancellationToken ) ;
48
49
if ( evaluationResult == null ) continue ;
49
50
var valueToken = JToken . FromObject ( evaluationResult ) ;
50
51
var value = null as string ;
@@ -62,6 +63,19 @@ public static class IWorkflowRuntimeContextExtensions
62
63
return JsonConvert . DeserializeObject < ExpandoObject > ( json ) ! ;
63
64
}
64
65
66
+ /// <summary>
67
+ /// Evaluates an object against the specified data
68
+ /// </summary>
69
+ /// <param name="context">The current <see cref="IWorkflowRuntimeContext"/></param>
70
+ /// <param name="expressionObject">The object to evaluate</param>
71
+ /// <param name="data">The data to evaluate the object against</param>
72
+ /// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
73
+ /// <returns>The evaluated object</returns>
74
+ public static Task < object ? > EvaluateObjectAsync ( this IWorkflowRuntimeContext context , object expressionObject , object data , CancellationToken cancellationToken = default )
75
+ {
76
+ return EvaluateObjectAsync ( context , expressionObject , data , null , cancellationToken ) ;
77
+ }
78
+
65
79
/// <summary>
66
80
/// Evaluates the specified condition expression
67
81
/// </summary>
@@ -123,9 +137,7 @@ public static async Task<bool> EvaluateConditionAsync(this IWorkflowRuntimeConte
123
137
/// <returns>The filtered output</returns>
124
138
public static async Task < object ? > FilterOutputAsync ( this IWorkflowRuntimeContext context , StateDefinition state , object output , CancellationToken cancellationToken = default )
125
139
{
126
- if ( state . DataFilter == null
127
- || string . IsNullOrWhiteSpace ( state . DataFilter . Output ) )
128
- return output ;
140
+ if ( state . DataFilter == null || string . IsNullOrWhiteSpace ( state . DataFilter . Output ) ) return output ;
129
141
return await context . EvaluateAsync ( state . DataFilter . Output , output , cancellationToken ) ;
130
142
}
131
143
@@ -135,14 +147,28 @@ public static async Task<bool> EvaluateConditionAsync(this IWorkflowRuntimeConte
135
147
/// <param name="context">The <see cref="IWorkflowRuntimeContext"/> to use</param>
136
148
/// <param name="action">The <see cref="ActionDefinition"/> to filter the output for</param>
137
149
/// <param name="output">The output data to filter</param>
150
+ /// <param name="authorization">The current <see cref="AuthorizationInfo"/>, if any</param>
138
151
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
139
152
/// <returns>The filtered output</returns>
140
- public static async Task < object ? > FilterOutputAsync ( this IWorkflowRuntimeContext context , ActionDefinition action , object output , CancellationToken cancellationToken = default )
153
+ public static async Task < object ? > FilterOutputAsync ( this IWorkflowRuntimeContext context , ActionDefinition action , object output , AuthorizationInfo ? authorization , CancellationToken cancellationToken = default )
141
154
{
142
155
if ( action . ActionDataFilter == null
143
156
|| string . IsNullOrWhiteSpace ( action . ActionDataFilter . Results ) )
144
157
return output ;
145
- return await context . EvaluateAsync ( action . ActionDataFilter . Results , output , cancellationToken ) ;
158
+ return await context . EvaluateAsync ( action . ActionDataFilter . Results , output , authorization , cancellationToken ) ;
159
+ }
160
+
161
+ /// <summary>
162
+ /// Filters the output of the specified <see cref="ActionDefinition"/>
163
+ /// </summary>
164
+ /// <param name="context">The <see cref="IWorkflowRuntimeContext"/> to use</param>
165
+ /// <param name="action">The <see cref="ActionDefinition"/> to filter the output for</param>
166
+ /// <param name="output">The output data to filter</param>
167
+ /// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
168
+ /// <returns>The filtered output</returns>
169
+ public static Task < object ? > FilterOutputAsync ( this IWorkflowRuntimeContext context , ActionDefinition action , object output , CancellationToken cancellationToken = default )
170
+ {
171
+ return FilterOutputAsync ( context , action , output , cancellationToken ) ;
146
172
}
147
173
148
174
/// <summary>
0 commit comments