public static IReadOnlyObservableValue <TTarget> Map <TSource, TTarget>( this IReadOnlyObservableValue <TSource> source, Func <TSource, TTarget> mapping) { return(new TransformingBinding <TSource, TTarget>(source, mapping)); }
public static IReadOnlyObservableValue <decimal> Divide(this IReadOnlyObservableValue <int> self, decimal other) { return(self.Map((a) => a / other)); }
public static IReadOnlyObservableValue <double> Add(this IReadOnlyObservableValue <int> self, double other) { return(self.Map((a) => a + other)); }
public static IReadOnlyObservableValue <double> Multiply(this IReadOnlyObservableValue <double> self, short other) { return(self.Map((a) => a * other)); }
public static IReadOnlyObservableValue <decimal> Multiply(this IReadOnlyObservableValue <decimal> self, byte other) { return(self.Map((a) => a * other)); }
public static IReadOnlyObservableValue <double> Subtract(this IReadOnlyObservableValue <double> self, short other) { return(self.Map((a) => a - other)); }
public static IReadOnlyObservableValue <long> Multiply(this IReadOnlyObservableValue <int> self, long other) { return(self.Map((a) => a * other)); }
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."); }
public static IReadOnlyObservableValue <T> Map <T>(this IReadOnlyObservableValue <bool> that, T onTrue, T onFalse) { return(that.Map((b) => b ? onTrue: onFalse)); }
public static IReadOnlyObservableValue <T> OrElse <T>(this IReadOnlyObservableValue <T> source, IReadOnlyObservableValue <T> fallback) where T : class { return(Combine(source, fallback, (a, b) => a ?? b)); }
public static IReadOnlyObservableValue Combine(IReadOnlyObservableValue sourceA, IReadOnlyObservableValue sourceB, Func <object, object, object> mapper) { return(new DelegateBoundBinding <object>(() => mapper(sourceA.Value, sourceB.Value), sourceA, sourceB)); }
public static IReadOnlyObservableValue OrElse <T>(this IReadOnlyObservableValue <T> source, T fallback) where T : class { return(source.Map(v => v ?? fallback)); }
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)); }
public static IReadOnlyObservableValue Filter(this IReadOnlyObservableValue source, Func <object, bool> filter, object defaultValue = null) { return(source.Map(v => filter(v) ? v : defaultValue)); }
public static IReadOnlyObservableValue <long> Subtract(this IReadOnlyObservableValue <int> self, long other) { return(self.Map((a) => a - other)); }
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)); }
public static IReadOnlyObservableValue <float> Subtract(this IReadOnlyObservableValue <float> self, int other) { return(self.Map((a) => a - other)); }
public static IReadOnlyObservableValue <bool> NotNull <T>(this IReadOnlyObservableValue <T> that) where T : class { return(that.Map(b => (b != null))); }
public static IReadOnlyObservableValue <decimal> Subtract(this IReadOnlyObservableValue <decimal> self, byte other) { return(self.Map((a) => a - other)); }
public static IReadOnlyObservableValue <bool> Not(this IReadOnlyObservableValue <bool> that) { return(that.Map(b => !b)); }
public static IReadOnlyObservableValue <float> Multiply(this IReadOnlyObservableValue <float> self, int other) { return(self.Map((a) => a * other)); }
public static IReadOnlyObservableValue <bool> EqualTo <T>(this IReadOnlyObservableValue <T> that, T other) { return(that.Map(b => Equals(b, other))); }
public static IReadOnlyObservableValue <long> Add(this IReadOnlyObservableValue <long> self, long other) { return(self.Map((a) => a + other)); }
public static IReadOnlyObservableValue <bool> EqualTo <T>(this IReadOnlyObservableValue <T> that, IReadOnlyObservableValue <T> other) where T : class { return(Binding.Combine(that, other, Equals)); }
public static IReadOnlyObservableValue <long> Divide(this IReadOnlyObservableValue <int> self, long other) { return(self.Map((a) => a / other)); }
public static IReadOnlyObservableValue <bool> And(this IReadOnlyObservableValue <bool> that, IReadOnlyObservableValue <bool> other) { return(Binding.Combine(that, other, (a, b) => a && b)); }
public static IReadOnlyObservableValue <float> Divide(this IReadOnlyObservableValue <float> self, byte other) { return(self.Map((a) => a / other)); }
public static IReadOnlyObservableValue <decimal> Add(this IReadOnlyObservableValue <decimal> self, short other) { return(self.Map((a) => a + other)); }
public static IReadOnlyObservableValue <double> Divide(this IReadOnlyObservableValue <double> self, double other) { return(self.Map((a) => a / other)); }
public static IReadOnlyObservableValue Map(this IReadOnlyObservableValue source, Func <object, object> mapping) { return(new TransformingBinding(source, mapping)); }