Пример #1
0
        /// <summary>
        /// Creates an incremental expression for the given code expression
        /// </summary>
        /// <typeparam name="T">The type of the expression</typeparam>
        /// <param name="expression">The expression from which to create an incremental expression</param>
        /// <param name="parameterMappings">A given mapping of parameters</param>
        /// <param name="parameters">The parameters of the expression</param>
        /// <returns>An incremental expression object</returns>
        public INotifyReversableExpression <T> CreateReversableExpression <T>(Expression expression, IEnumerable <ParameterExpression> parameters, IDictionary <string, object> parameterMappings)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            INotifyReversableExpression <T> exp;

            if (parameterMappings == null)
            {
                binder.Compress = parameters == null;
                exp             = binder.VisitObservable <T>(expression, false) as INotifyReversableExpression <T>;
            }
            else
            {
                var newBinder = new ObservableExpressionBinder(parameters == null, parameterMappings);
                exp = newBinder.VisitObservable <T>(expression, false) as INotifyReversableExpression <T>;
            }
            if (exp == null)
            {
                throw new InvalidOperationException("The given expression could not be reversed!");
            }
            return(exp);
        }
Пример #2
0
 public ObservableReversableBinaryExpression(BinaryExpression node, ObservableExpressionBinder binder, MethodInfo leftReverser, MethodInfo rightReverser)
     : this(
         binder.VisitObservable <TLeft>(node.Left),
         binder.VisitObservable <TRight>(node.Right),
         ReflectionHelper.CreateDelegate <Func <TLeft, TRight, TResult> >(node.Method),
         rightReverser != null ? ReflectionHelper.CreateDelegate <Func <TResult, TRight, TLeft> >(rightReverser) : null,
         leftReverser != null ? ReflectionHelper.CreateDelegate <Func <TResult, TLeft, TRight> >(leftReverser) : null)
 {
 }
Пример #3
0
        /// <summary>
        /// Creates an incremental expression for the given code expression
        /// </summary>
        /// <typeparam name="T">The type of the expression</typeparam>
        /// <param name="expression">The expression from which to create an incremental expression</param>
        /// <param name="parameterMappings">A given mapping of parameters</param>
        /// <param name="parameters">The parameters of the expression</param>
        /// <returns>An incremental expression object</returns>
        public INotifyExpression CreateExpression(Expression expression, IEnumerable <ParameterExpression> parameters, IDictionary <string, object> parameterMappings)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            if (parameterMappings == null)
            {
                return(binder.VisitObservable(expression, false));
            }
            else
            {
                var newBinder = new ObservableExpressionBinder(false, parameterMappings);
                return(newBinder.VisitObservable(expression, false));
            }
        }
Пример #4
0
 public ObservableBinaryExpression(BinaryExpression node, ObservableExpressionBinder binder)
     : this(binder.VisitObservable <TLeft>(node.Left), binder.VisitObservable <TRight>(node.Right), ReflectionHelper.CreateDelegate <Func <TLeft, TRight, TResult> >(node.Method))
 {
 }
 public ObservableConditionalExpression(ConditionalExpression expression, ObservableExpressionBinder binder)
     : this(binder.VisitObservable <bool>(expression.Test), binder.VisitObservable <T>(expression.IfTrue), binder.VisitObservable <T>(expression.IfFalse))
 {
 }
Пример #6
0
 private ObservableMemberInit(MemberInitExpression expression, ObservableExpressionBinder binder, INotifyExpression <T> inner)
     : this(inner, expression.Bindings.Select(m => binder.VisitMemberBinding(m, inner)))
 {
 }
Пример #7
0
 public ObservableUnaryExpression(UnaryExpression node, ObservableExpressionBinder binder)
     : this(binder.VisitObservable <TInner>(node.Operand), ReflectionHelper.CreateDelegate <Func <TInner, TOuter> >(node.Method))
 {
 }
Пример #8
0
 public ObservableTypeAs(UnaryExpression node, ObservableExpressionBinder binder)
     : base(binder.VisitObservable <TInner>(node.Operand))
 {
 }
Пример #9
0
 public ObservableListInitializer(ElementInit expression, ObservableExpressionBinder binder, INotifyExpression <T> target)
     : this(target, binder.VisitObservable <TElement>(expression.Arguments[0]), expression.AddMethod)
 {
 }
Пример #10
0
 public InstructionLevelNotifySystem()
 {
     binder = CreateBinder();
 }
Пример #11
0
        public ObservableStaticLensMethodCall(MethodCallExpression node, ObservableExpressionBinder binder) : base(node, binder)
        {
            var lensPutAttribute = node.Method.GetCustomAttribute(typeof(LensPutAttribute)) as LensPutAttribute;

            LensPut = LensPut <T1, TResult> .FromLensPutAttribute(lensPutAttribute, node.Method, Argument1 as INotifyReversableValue <T1>);
        }
Пример #12
0
 public ObservableListInit(ListInitExpression expression, ObservableExpressionBinder binder)
     : this(expression, binder, binder.VisitObservable <T>(expression.NewExpression))
 {
 }
Пример #13
0
 public ObservablePropertyMemberBinding(MemberAssignment node, ObservableExpressionBinder binder, INotifyExpression <T> target, Action <T, TMember> member)
     : this(target, member, binder.VisitObservable <TMember>(node.Expression))
 {
 }
Пример #14
0
 public ObservablePropertyMemberBinding(MemberAssignment node, ObservableExpressionBinder binder, INotifyExpression <T> target, FieldInfo field)
     : this(target, ReflectionHelper.CreateDynamicFieldSetter <T, TMember>(field), binder.VisitObservable <TMember>(node.Expression))
 {
 }
Пример #15
0
 public ObservableArrayInitializationExpression(NewArrayExpression node, ObservableExpressionBinder binder)
     : this(node.Expressions.Select(e => binder.VisitObservable <T>(e)))
 {
 }
 public ObservableMemberExpression(MemberExpression expression, ObservableExpressionBinder binder, string name, Func <TTarget, TMember> getter)
     : this(binder.VisitObservable <TTarget>(expression.Expression, true), name, getter)
 {
 }
 public ObservableReversableMemberExpression(MemberExpression expression, ObservableExpressionBinder binder, string name, FieldInfo field)
     : this(binder.VisitObservable <TTarget>(expression.Expression, true), name, ReflectionHelper.CreateDynamicFieldGetter <TTarget, TMember>(field), ReflectionHelper.CreateDynamicFieldSetter <TTarget, TMember>(field))
 {
 }
Пример #18
0
 public ObservableCoalesceExpression(BinaryExpression expression, ObservableExpressionBinder binder)
     : this(binder.VisitObservable <T>(expression.Left), binder.VisitObservable <T>(expression.Right))
 {
 }
Пример #19
0
 public ObservableLongArrayIndex(BinaryExpression node, ObservableExpressionBinder binder)
     : this(binder.VisitObservable <T[]>(node.Left), binder.VisitObservable <long>(node.Right))
 {
 }
Пример #20
0
 private ObservableListInit(ListInitExpression expression, ObservableExpressionBinder binder, INotifyExpression <T> inner)
     : base(inner, expression.Initializers.Select(e => binder.VisitElementInit <T>(e, inner)))
 {
 }
Пример #21
0
        public ObservableMethodLensProxyCall(MethodCallExpression node, ObservableExpressionBinder binder, MethodInfo proxyMethod) : base(node, binder, proxyMethod)
        {
            var lensPutAttribute = node.Method.GetCustomAttribute(typeof(LensPutAttribute)) as LensPutAttribute;

            LensPut = LensPut <T, TResult> .FromLensPutAttribute(lensPutAttribute, node.Method, Target as INotifyReversableValue <T>);
        }
Пример #22
0
 public ObservableNewExpression(NewExpression node, ObservableExpressionBinder binder)
     : base(CreateDelegate(node), binder.VisitObservable <T1>(node.Arguments[0]))
 {
 }
        private static ObservableMemberBinding <T> CreateProperty <T, TMember>(MemberAssignment node, ObservableExpressionBinder binder, INotifyExpression <T> target)
        {
            INotifyExpression <TMember> value = binder.VisitObservable <TMember>(node.Expression);
            var property   = node.Member as PropertyInfo;
            var reversable = value as INotifyReversableExpression <TMember>;

            if (reversable != null && ReflectionHelper.IsAssignableFrom(typeof(INotifyPropertyChanged), typeof(T)))
            {
                return(new ObservableReversablePropertyMemberBinding <T, TMember>(target, node.Member.Name,
                                                                                  ReflectionHelper.CreateDelegate(typeof(Func <T, TMember>), ReflectionHelper.GetGetter(property)) as Func <T, TMember>,
                                                                                  ReflectionHelper.CreateDelegate(typeof(Action <T, TMember>), ReflectionHelper.GetSetter(property)) as Action <T, TMember>,
                                                                                  reversable));
            }
            return(new ObservablePropertyMemberBinding <T, TMember>(target,
                                                                    ReflectionHelper.CreateDelegate(typeof(Action <T, TMember>), ReflectionHelper.GetSetter(property)) as Action <T, TMember>, value));
        }