Exemplo n.º 1
0
        private static Action <IBindingBuilder>[] ConvertInternal(LambdaExpression expression, IBindingBuilder builder, bool ignoreCallback)
        {
            Expression lastExpression;
            string     path;

            if (BindingExtensions.TryGetMemberPath(expression.Body, ".", false, out lastExpression, out path) &&
                expression.Parameters[0] == lastExpression)
            {
                if (ignoreCallback)
                {
                    builder.GetOrAddBindingSources().Add(context => BindingExtensions.CreateBindingSource(context, path, null));
                    return(Empty.Array <Action <IBindingBuilder> >());
                }
                return(new Action <IBindingBuilder>[] { b => b.GetOrAddBindingSources().Add(context => BindingExtensions.CreateBindingSource(context, path, null)) });
            }
            var visitor = new LambdaExpressionToBindingExpressionConverter(expression);

            visitor.ConvertInternal(expression);
            var actions = visitor._callbacks.ToArray();

            visitor._members           = null;
            visitor._sourceExpression  = null;
            visitor._currentExpression = null;
            visitor._methodExpression  = null;
            visitor._callbacks         = null;
            return(actions);
        }