Beispiel #1
0
        private Action <IStepBody, object, IStepExecutionContext> BuildScalarInputAction(KeyValuePair <string, object> input, PropertyInfo stepProperty)
        {
            var sourceExpr = System.Convert.ToString(input.Value);

            void acn(IStepBody pStep, object pData, IStepExecutionContext pContext)
            {
                var resolvedValue = _expressionEvaluator.EvaluateExpression(sourceExpr, pData, pContext);

                if (pStep is CustomStep)
                {
                    (pStep as CustomStep)[input.Key] = resolvedValue;
                    return;
                }

                if (stepProperty.PropertyType.IsEnum)
                {
                    stepProperty.SetValue(pStep, Enum.Parse(stepProperty.PropertyType, (string)resolvedValue, true));
                }
                else
                {
                    stepProperty.SetValue(pStep, System.Convert.ChangeType(resolvedValue, stepProperty.PropertyType));
                }
            }

            return(acn);
        }