コード例 #1
0
        /// <summary>
        /// Given a text expression and runtimeArgs, evaluate the expression.
        /// Expressions must be compatible with DataColumn.Expression. the result is cast to T
        /// </summary>

        internal static object EvaluateExpressionImpl(WfExpression wfExpression, IRunState context, IDictionary <string, Resource> knownEntities)
        {
            var expression = context.Metadata.CompiledExpressionCache[wfExpression.Id];

            if (expression == null)
            {
                return(GetKnownEntities(wfExpression, knownEntities));
            }
            else
            {
                // Evaluate the expression
                var eSettings = new EvaluationSettings();
                eSettings.TimeZoneName = TimeZoneHelper.SydneyTimeZoneName;                                         // TODO: Workflow engine to provide a timezone to run in. Required for date-time functions.

                eSettings.ParameterResolver = paramName => context.ResolveParameterValue(paramName, knownEntities); // used for runtime parameters

                object result = Factory.ExpressionRunner.Run(expression, eSettings).Value;
                return(CoerceToListIfNeeded(wfExpression, result));
            }
        }