private string FormatSearchTerm(string searchTerm, MembershipProvider m, ValuePredicateType predicateType)
        {
            var wildcard = _configuredProviders.Single(x => x.Name == m.Name).WildcardCharacter;

            switch (predicateType)
            {
            case ValuePredicateType.Equal:
            case ValuePredicateType.NotEqual:
            case ValuePredicateType.LessThan:
            case ValuePredicateType.GreaterThan:
            case ValuePredicateType.LessThanOrEqual:
            case ValuePredicateType.GreaterThanOrEqual:
            case ValuePredicateType.Empty:
                //we currently dont change the value for any of the above.
                return(searchTerm);

            case ValuePredicateType.StartsWith:
                return(searchTerm + wildcard);

            case ValuePredicateType.EndsWith:
                return(wildcard + searchTerm);

            case ValuePredicateType.Contains:
            case ValuePredicateType.MatchesWildcard:
                return(wildcard + searchTerm + wildcard);

            default:
                throw new ArgumentOutOfRangeException("predicateType");
            }
        }
예제 #2
0
 public AssertingCriteriaVisitor(string fieldName, object fieldValue, ValuePredicateType valuePredicateType, string subFieldName = null)
 {
     _valuePredicateType = valuePredicateType;
     _fieldValue         = fieldValue;
     _fieldName          = fieldName;
     _subFieldName       = subFieldName;
 }
 public IEnumerable <T> PerformGetByEmail <T>(string email, ValuePredicateType predicateType)
 {
     return(GetAllPagedData <T>((m, i) =>
     {
         int totalUsers;
         var result = m.FindUsersByEmail(FormatSearchTerm(email, m, predicateType), i, 1000, out totalUsers);
         return new Tuple <MembershipUserCollection, int>(result, totalUsers);
     }));
 }
예제 #4
0
        private static SimpleExpression CreateRestriction(ValuePredicateType clauseType, Expression <Func <object> > projection, object value)
        {
            switch (clauseType)
            {
            case ValuePredicateType.LessThanOrEqual:
                return(Restrictions.Le(Projections.Property(projection), value));

            case ValuePredicateType.LessThan:
                return(Restrictions.Lt(Projections.Property(projection), value));

            case ValuePredicateType.Equal:
                return(Restrictions.Eq(Projections.Property(projection), value));

            case ValuePredicateType.GreaterThan:
                return(Restrictions.Gt(Projections.Property(projection), value));

            case ValuePredicateType.GreaterThanOrEqual:
                return(Restrictions.Ge(Projections.Property(projection), value));

            default:
                throw new InvalidOperationException("Unsupport clause type");
            }
        }
예제 #5
0
        public static void Check(Expression criteria, string fieldName, object fieldValue, ValuePredicateType valuePredicateType, string subFieldName = null)
        {
            var assertingVisitor = new AssertingCriteriaVisitor(fieldName, fieldValue, valuePredicateType, subFieldName);

            assertingVisitor.Visit(criteria);
            Assert.IsTrue(assertingVisitor.FoundMatch, "Found no expression for {0} {1} {2}. Found: {3}".InvariantFormat(fieldName, valuePredicateType.ToString(), fieldValue, assertingVisitor.MatchesFound));
        }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldValueExpression"/> class.
 /// </summary>
 /// <param name="clauseType">Type of the clause.</param>
 /// <param name="value">The value.</param>
 /// <remarks></remarks>
 public SchemaValueExpression(ValuePredicateType clauseType, object value)
 {
     ClauseType = clauseType;
     Value      = value;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldValueExpression"/> class.
 /// </summary>
 /// <param name="clauseType">Type of the clause.</param>
 /// <param name="value">The value.</param>
 /// <remarks></remarks>
 public FieldValueExpression(ValuePredicateType clauseType, object value)
 {
     ClauseType = clauseType;
     Value = value;
 }
 public MembershipProviderQuery(MembershipQueryType type, object searchValue, ValuePredicateType predicateType)
     : this(type)
 {
     SearchValue = searchValue;
     SearchTermPredicateType = predicateType;
 }
예제 #9
0
 public SchemaPredicateExpression(string name, ValuePredicateType predicateType, object value)
     : this(new SchemaSelectorExpression(name), new SchemaValueExpression(predicateType, value))
 {
 }
 public FieldPredicateExpression(string fieldName, string subFieldName, ValuePredicateType predicateType, object value)
     : this(new FieldSelectorExpression(fieldName, subFieldName), new FieldValueExpression(predicateType, value))
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BindingSignatureSupport"/> class.
 /// </summary>
 /// <param name="signatureSupportType">Type of the signature support.</param>
 /// <param name="nodeType">Type of the node.</param>
 /// <remarks></remarks>
 public BindingSignatureSupport(SignatureSupportType signatureSupportType, ValuePredicateType nodeType)
 {
     SignatureSupportType = signatureSupportType;
     NodeType = nodeType;
 }
 public MembershipProviderQuery(MembershipQueryType type, object searchValue, ValuePredicateType predicateType)
     : this(type)
 {
     SearchValue             = searchValue;
     SearchTermPredicateType = predicateType;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BindingSignatureSupport"/> class.
 /// </summary>
 /// <param name="signatureSupportType">Type of the signature support.</param>
 /// <param name="nodeType">Type of the node.</param>
 /// <remarks></remarks>
 public BindingSignatureSupport(SignatureSupportType signatureSupportType, ValuePredicateType nodeType)
 {
     SignatureSupportType = signatureSupportType;
     NodeType = nodeType;
 }