Пример #1
0
        public override VariableValue Evaluate(IVariableStore variables)
        {
            var left  = Left.Evaluate(variables);
            var value = VariableHandler.Cast(left, _rightIdentifier.Name);

            if (value.IsEmpty)
            {
                throw new ExpressionEvaluationException(_invalidCastException, left, _rightIdentifier.Name);
            }

            if (!value.IsEmpty && !left.HasReference)
            {
                if (Left is IAssignableOperation assignable)
                {
                    var result = assignable.SetValue(variables, value);

                    if (result == SetVariableResult.Success)
                    {
                        return(value);
                    }
                }

                throw new ExpressionEvaluationException(_invalidAssignException, value, left, Left);
            }

            return(value);
        }
Пример #2
0
        public VariableValue GetValue(IVariableStore variables, VariableValue owner)
        {
            var left = Left is ILookupOperation lookup?lookup.GetValue(variables, owner) : VariableValue.Empty;

            return(left.IsEmpty ? left : VariableHandler.Cast(left, _rightIdentifier.Name));
        }