public static IFluentContinuation <TViewModel, TPropertyValue> BetweenPoperties <TViewModel, TPropertyValue>( this IFluentOperator <TViewModel, TPropertyValue> instance, Expression <Func <TViewModel, IViewModelProperty> > @from, Expression <Func <TViewModel, IViewModelProperty> > to) where TViewModel : ViewModelBase { var implementerInstance = (FluentImplementer <TViewModel, TPropertyValue>)instance; implementerInstance.EnsureContextCurrentPropertyIsNotNull(); implementerInstance.UpdateContext(@from); implementerInstance.UpdateContext(to); // uses parenthesis to satisfy syntax : IsNot.BetweenValues (...) implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.GreaterThanProperty(implementerInstance.Context.CurrentProperty, @from.Compile()(implementerInstance.ViewModel))); implementerInstance.AddToken(ExpressionNode.Or()); implementerInstance.AddToken(ExpressionNode.EqualToProperty(implementerInstance.Context.CurrentProperty, @from.Compile()(implementerInstance.ViewModel))); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); implementerInstance.AddToken(ExpressionNode.And()); implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.LessThanProperty(implementerInstance.Context.CurrentProperty, to.Compile()(implementerInstance.ViewModel))); implementerInstance.AddToken(ExpressionNode.Or()); implementerInstance.AddToken(ExpressionNode.EqualToProperty(implementerInstance.Context.CurrentProperty, to.Compile()(implementerInstance.ViewModel))); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); return((IFluentContinuation <TViewModel, TPropertyValue>)instance); }
public static IFluentContinuation <TViewModel, TPropertyValue> BetweenValues <TViewModel, TPropertyValue>( this IFluentOperator <TViewModel, TPropertyValue> instance, object @from, object to) where TViewModel : ViewModelBase { var implementerInstance = (FluentImplementer <TViewModel, TPropertyValue>)instance; implementerInstance.EnsureContextCurrentPropertyIsNotNull(); // uses parenthesis to satisfy syntax : IsNot.BetweenValues (...) implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.GreaterThanValue(implementerInstance.Context.CurrentProperty, @from)); implementerInstance.AddToken(ExpressionNode.Or()); implementerInstance.AddToken(ExpressionNode.EqualToValue(implementerInstance.Context.CurrentProperty, @from)); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); implementerInstance.AddToken(ExpressionNode.And()); implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.LessThanValue(implementerInstance.Context.CurrentProperty, to)); implementerInstance.AddToken(ExpressionNode.Or()); implementerInstance.AddToken(ExpressionNode.EqualToValue(implementerInstance.Context.CurrentProperty, to)); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); return((IFluentContinuation <TViewModel, TPropertyValue>)instance); }
public static IFluentContinuation <TViewModel, TPropertyValue> MinLength <TViewModel, TPropertyValue>( this IFluentOperator <TViewModel, TPropertyValue> instance, int minLength) where TViewModel : ViewModelBase where TPropertyValue : IComparable <string>, IEquatable <string> { var implementerInstance = (FluentImplementer <TViewModel, TPropertyValue>)instance; implementerInstance.EnsureContextCurrentPropertyIsNotNull(); if (minLength <= 0) { throw new InvalidOperationException("minLength must be greater than 0"); } var evaluatedValueProvider = new Func <object>(() => { var value = (string)implementerInstance.Context.CurrentProperty.GetValue(); return(value == null ? 0 : value.Length); }); var valueProvider = new Func <object>(() => minLength); implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.GreaterThanGeneric(evaluatedValueProvider, valueProvider)); implementerInstance.AddToken(ExpressionNode.Or()); implementerInstance.AddToken(ExpressionNode.EqualToGeneric(evaluatedValueProvider, valueProvider)); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); return((IFluentContinuation <TViewModel, TPropertyValue>)instance); }
public static IFluentContinuation <TViewModel, TPropertyValue> GreaterThanOrEqualTo <TViewModel, TPropertyValue>( this IFluentOperator <TViewModel, TPropertyValue> instance, LateValue <TPropertyValue> lateValue) where TViewModel : ViewModelBase where TPropertyValue : IComparable { var implementerInstance = (FluentImplementer <TViewModel, TPropertyValue>)instance; implementerInstance.EnsureContextCurrentPropertyIsNotNull(); implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.GreaterThanLateValue(implementerInstance.Context.CurrentProperty, () => lateValue())); implementerInstance.AddToken(ExpressionNode.Or()); implementerInstance.AddToken(ExpressionNode.EqualToLateValue(implementerInstance.Context.CurrentProperty, () => lateValue())); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); return((IFluentContinuation <TViewModel, TPropertyValue>)instance); }
public static IFluentContinuation <TViewModel, TPropertyValue> NullOrEmpty <TViewModel, TPropertyValue>( this IFluentOperator <TViewModel, TPropertyValue> instance) where TViewModel : ViewModelBase where TPropertyValue : IComparable <string>, IEquatable <string> { var implementerInstance = (FluentImplementer <TViewModel, TPropertyValue>)instance; implementerInstance.EnsureContextCurrentPropertyIsNotNull(); implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.EqualToValue(implementerInstance.Context.CurrentProperty, null)); implementerInstance.AddToken(ExpressionNode.Or()); implementerInstance.AddToken(ExpressionNode.EqualToValue(implementerInstance.Context.CurrentProperty, string.Empty)); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); return((IFluentContinuation <TViewModel, TPropertyValue>)instance); }
public static IFluentContinuation <TViewModel, TPropertyValue> GreaterThanOrEqualTo <TViewModel, TPropertyValue>( this IFluentOperator <TViewModel, TPropertyValue> instance, Expression <Func <TViewModel, IViewModelProperty> > propertyExpression) where TViewModel : ViewModelBase where TPropertyValue : IComparable { var implementerInstance = (FluentImplementer <TViewModel, TPropertyValue>)instance; implementerInstance.EnsureContextCurrentPropertyIsNotNull(); implementerInstance.UpdateContext(propertyExpression); implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.GreaterThanProperty(implementerInstance.Context.CurrentProperty, propertyExpression.Compile()(implementerInstance.ViewModel))); implementerInstance.AddToken(ExpressionNode.Or()); implementerInstance.AddToken(ExpressionNode.EqualToProperty(implementerInstance.Context.CurrentProperty, propertyExpression.Compile()(implementerInstance.ViewModel))); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); return((IFluentContinuation <TViewModel, TPropertyValue>)instance); }
public static IFluentContinuation <TViewModel, TPropertyValue> Required <TViewModel, TPropertyValue>( this IFluentOperator <TViewModel, TPropertyValue> instance) where TViewModel : ViewModelBase { var implementerInstance = (FluentImplementer <TViewModel, TPropertyValue>)instance; implementerInstance.EnsureContextCurrentPropertyIsNotNull(); // required = is neither null nor empty implementerInstance.AddToken(ExpressionNode.Not()); implementerInstance.AddToken(ExpressionNode.OpenParenthesis()); implementerInstance.AddToken(ExpressionNode.EqualToValue(implementerInstance.Context.CurrentProperty, null)); implementerInstance.AddToken(ExpressionNode.Or()); implementerInstance.AddToken(ExpressionNode.EqualToValue(implementerInstance.Context.CurrentProperty, string.Empty)); implementerInstance.AddToken(ExpressionNode.CloseParenthesis()); return((IFluentContinuation <TViewModel, TPropertyValue>)instance); }