private static void EvaluateMemeberAssignment(EvaluatedMemberBinding result, MemberAssignment assignment,
                                                      List <NodeReference> references, DataContext context)
        {
            var processingResult = ExpressionProcessingHelper.ProcessExpression(assignment.Expression, references, context);

            result.AddResult(LoadData(processingResult, assignment.Expression.Type));
        }
        internal static List <EvaluatedMemberBinding> EvaluateBindings(List <MemberBinding> bindings,
                                                                       List <NodeReference> references, DataContext context)
        {
            var result = new List <EvaluatedMemberBinding>();

            foreach (var memberBinding in bindings)
            {
                var item = new EvaluatedMemberBinding(memberBinding.BindingType, memberBinding.Member);

                switch (memberBinding.BindingType)
                {
                case MemberBindingType.Assignment:
                    EvaluateMemeberAssignment(item, memberBinding as MemberAssignment, references, context);
                    break;

                case MemberBindingType.ListBinding:
                    EvaluateListBinding(item, memberBinding as MemberListBinding, references, context);
                    break;

                case MemberBindingType.MemberBinding:
                    EvaluateMemberBinding(item, memberBinding as MemberMemberBinding, references, context);
                    break;
                }

                result.Add(item);

                if (!item.IsSuccess)
                {
                    return(result);
                }
            }

            return(result);
        }
Example #3
0
        internal void AddChildBinding(EvaluatedMemberBinding binding)
        {
            if (!binding.IsSuccess)
            {
                IsSuccess = false;
            }

            if (!binding.IsSingle)
            {
                IsSingle = false;
            }

            EvaluatedBindings.Add(binding);
        }
        private static void EvaluateMemberBinding(EvaluatedMemberBinding result, MemberMemberBinding memberBinding,
                                                  List <NodeReference> references, DataContext context)
        {
            var childMemberBindings = EvaluateBindings(memberBinding.Bindings.ToList(), references, context);

            if (childMemberBindings.Any(b => !b.IsSuccess))
            {
                result.MarkUnsuccessful();
                return;
            }

            foreach (var evaluatedMemberBinding in childMemberBindings)
            {
                result.AddChildBinding(evaluatedMemberBinding);
            }
        }
        private static void EvaluateListBinding(EvaluatedMemberBinding result, MemberListBinding listBinding,
                                                List <NodeReference> references, DataContext context)
        {
            foreach (var initializer in listBinding.Initializers)
            {
                var processingResults = initializer.Arguments
                                        .Select(a => LoadData(ExpressionProcessingHelper.ProcessExpression(a, references, context), a.Type))
                                        .ToList();

                if (processingResults.Any(r => !r.IsSuccess))
                {
                    result.MarkUnsuccessful();
                    return;
                }

                result.AddInitializer(initializer.AddMethod, processingResults);
            }
        }