Esempio n. 1
0
 public static IReadOnlyObservableValue <TTarget> Map <TSource, TTarget>(
     this IReadOnlyObservableValue <TSource> source,
     Func <TSource, TTarget> mapping)
 {
     return(new TransformingBinding <TSource, TTarget>(source, mapping));
 }
Esempio n. 2
0
 public static IReadOnlyObservableValue <decimal> Divide(this IReadOnlyObservableValue <int> self,
                                                         decimal other)
 {
     return(self.Map((a) => a / other));
 }
Esempio n. 3
0
 public static IReadOnlyObservableValue <double> Add(this IReadOnlyObservableValue <int> self,
                                                     double other)
 {
     return(self.Map((a) => a + other));
 }
Esempio n. 4
0
 public static IReadOnlyObservableValue <double> Multiply(this IReadOnlyObservableValue <double> self,
                                                          short other)
 {
     return(self.Map((a) => a * other));
 }
Esempio n. 5
0
 public static IReadOnlyObservableValue <decimal> Multiply(this IReadOnlyObservableValue <decimal> self,
                                                           byte other)
 {
     return(self.Map((a) => a * other));
 }
Esempio n. 6
0
 public static IReadOnlyObservableValue <double> Subtract(this IReadOnlyObservableValue <double> self,
                                                          short other)
 {
     return(self.Map((a) => a - other));
 }
Esempio n. 7
0
 public static IReadOnlyObservableValue <long> Multiply(this IReadOnlyObservableValue <int> self,
                                                        long other)
 {
     return(self.Map((a) => a * other));
 }
Esempio n. 8
0
        static IReadOnlyObservableValue CreateRecursively(Expression currentExpression, IReadOnlyObservableValue source)
        {
            if (currentExpression is ConstantExpression constExpr)
            {
                return(new ConstBinding(constExpr.Value));
            }

            if (currentExpression is ParameterExpression)
            {
                if (source == null)
                {
                    throw new ArgumentException();
                }

                return(source);
            }

            if (!(currentExpression is MemberExpression memberExpr))
            {
                throw new ArgumentException($"Require member expression, found WHATEVER in lamda.");
            }

            var obs    = CreateRecursively(memberExpr.Expression, source);
            var member = memberExpr.Member;

            if (member.MemberType == MemberTypes.Field)
            {
                return(new PropertyMemberBinding(obs, (FieldInfo)member));
            }

            if (member.MemberType == MemberTypes.Property)
            {
                return(new PropertyMemberBinding(obs, (PropertyInfo)member));
            }

            throw new ArgumentException("Cannot have expression of type " + currentExpression.NodeType + " in call chain.");
        }
Esempio n. 9
0
 public static IReadOnlyObservableValue <T> Map <T>(this IReadOnlyObservableValue <bool> that,
                                                    T onTrue, T onFalse)
 {
     return(that.Map((b) => b ? onTrue: onFalse));
 }
Esempio n. 10
0
 public static IReadOnlyObservableValue <T> OrElse <T>(this IReadOnlyObservableValue <T> source,
                                                       IReadOnlyObservableValue <T> fallback) where T : class
 {
     return(Combine(source, fallback, (a, b) => a ?? b));
 }
Esempio n. 11
0
 public static IReadOnlyObservableValue Combine(IReadOnlyObservableValue sourceA,
                                                IReadOnlyObservableValue sourceB,
                                                Func <object, object, object> mapper)
 {
     return(new DelegateBoundBinding <object>(() => mapper(sourceA.Value, sourceB.Value), sourceA, sourceB));
 }
Esempio n. 12
0
 public static IReadOnlyObservableValue OrElse <T>(this IReadOnlyObservableValue <T> source, T fallback) where T : class
 {
     return(source.Map(v => v ?? fallback));
 }
Esempio n. 13
0
 public static IReadOnlyObservableValue Filter <T>(this IReadOnlyObservableValue <T> source, Func <T, bool> filter, T defaultValue = default(T))
 {
     return(source.Map(v => filter(v) ? v : defaultValue));
 }
Esempio n. 14
0
 public static IReadOnlyObservableValue Filter(this IReadOnlyObservableValue source, Func <object, bool> filter, object defaultValue = null)
 {
     return(source.Map(v => filter(v) ? v : defaultValue));
 }
Esempio n. 15
0
 public static IReadOnlyObservableValue <long> Subtract(this IReadOnlyObservableValue <int> self,
                                                        long other)
 {
     return(self.Map((a) => a - other));
 }
Esempio n. 16
0
 public static IReadOnlyObservableValue <T> Map <T>(this IReadOnlyObservableValue <bool> that,
                                                    IReadOnlyObservableValue <T> onTrueVal, IReadOnlyObservableValue <T> onFalseVal)
 {
     return(Binding.Combine(that, onTrueVal, onFalseVal, (b, onTrue, onFalse) => b ? onTrue: onFalse));
 }
Esempio n. 17
0
 public static IReadOnlyObservableValue <float> Subtract(this IReadOnlyObservableValue <float> self,
                                                         int other)
 {
     return(self.Map((a) => a - other));
 }
Esempio n. 18
0
 public static IReadOnlyObservableValue <bool> NotNull <T>(this IReadOnlyObservableValue <T> that) where T : class
 {
     return(that.Map(b => (b != null)));
 }
Esempio n. 19
0
 public static IReadOnlyObservableValue <decimal> Subtract(this IReadOnlyObservableValue <decimal> self,
                                                           byte other)
 {
     return(self.Map((a) => a - other));
 }
Esempio n. 20
0
 public static IReadOnlyObservableValue <bool> Not(this IReadOnlyObservableValue <bool> that)
 {
     return(that.Map(b => !b));
 }
Esempio n. 21
0
 public static IReadOnlyObservableValue <float> Multiply(this IReadOnlyObservableValue <float> self,
                                                         int other)
 {
     return(self.Map((a) => a * other));
 }
Esempio n. 22
0
 public static IReadOnlyObservableValue <bool> EqualTo <T>(this IReadOnlyObservableValue <T> that, T other)
 {
     return(that.Map(b => Equals(b, other)));
 }
Esempio n. 23
0
 public static IReadOnlyObservableValue <long> Add(this IReadOnlyObservableValue <long> self,
                                                   long other)
 {
     return(self.Map((a) => a + other));
 }
Esempio n. 24
0
 public static IReadOnlyObservableValue <bool> EqualTo <T>(this IReadOnlyObservableValue <T> that,
                                                           IReadOnlyObservableValue <T> other) where T : class
 {
     return(Binding.Combine(that, other, Equals));
 }
Esempio n. 25
0
 public static IReadOnlyObservableValue <long> Divide(this IReadOnlyObservableValue <int> self,
                                                      long other)
 {
     return(self.Map((a) => a / other));
 }
Esempio n. 26
0
 public static IReadOnlyObservableValue <bool> And(this IReadOnlyObservableValue <bool> that,
                                                   IReadOnlyObservableValue <bool> other)
 {
     return(Binding.Combine(that, other, (a, b) => a && b));
 }
Esempio n. 27
0
 public static IReadOnlyObservableValue <float> Divide(this IReadOnlyObservableValue <float> self,
                                                       byte other)
 {
     return(self.Map((a) => a / other));
 }
Esempio n. 28
0
 public static IReadOnlyObservableValue <decimal> Add(this IReadOnlyObservableValue <decimal> self,
                                                      short other)
 {
     return(self.Map((a) => a + other));
 }
Esempio n. 29
0
 public static IReadOnlyObservableValue <double> Divide(this IReadOnlyObservableValue <double> self,
                                                        double other)
 {
     return(self.Map((a) => a / other));
 }
Esempio n. 30
0
 public static IReadOnlyObservableValue Map(this IReadOnlyObservableValue source, Func <object, object> mapping)
 {
     return(new TransformingBinding(source, mapping));
 }