Exemplo n.º 1
0
        private static bool GreaterThanOrFalse(ExpressionType nodeType, object member, Property property, object value)
        {
            var serializedMember = SearchFilter.GetValue(property, FilterOperator.GreaterThan, member);
            var serializedValue  = SearchFilter.GetValue(property, FilterOperator.GreaterThan, value);

            double serializedMemberVal;
            double serializedValueVal;

            if (double.TryParse(serializedMember, out serializedMemberVal))
            {
                if (double.TryParse(serializedValue, out serializedValueVal))
                {
                    if (nodeType == ExpressionType.GreaterThan)
                    {
                        return(serializedMemberVal > serializedValueVal);
                    }
                    else
                    {
                        return(serializedMemberVal < serializedValueVal);
                    }
                }
            }

            return(false);
        }
        private void RemoveInvalidFilters()
        {
            foreach (var set in FilterSets)
            {
                var remove = new List <SearchFilter>();

                foreach (var filter in set)
                {
                    var attrib = filter.Property.GetEnumAttribute <FilterHandlerAttribute>();

                    if (attrib != null)
                    {
                        FilterOperator op    = filter.Operator;
                        string         value = SearchFilter.GetValue(filter.Property, filter.Operator, filter.Value);

                        if (!attrib.Handler.TryFilter(op, value))
                        {
                            if (strict)
                            {
                                if (attrib.Handler.Unsupported)
                                {
                                    throw Error.UnsupportedProperty(filter.Property);
                                }

                                throw Error.InvalidFilterValue(filter.Property, op, filter.Value.ToString(), attrib.Handler.ValidDescription);
                            }

                            remove.Add(filter);
                        }
                    }
                }

                foreach (var r in remove)
                {
                    set.Remove(r);
                }
            }
        }
Exemplo n.º 3
0
        public async Task <List <Conference> > GetConferencesAsync(SearchFilter filter = null)
        {
            var queryString = QueryString.Create(filter.GetValue());

            return((await _httpClient.GetFromJsonAsync <ConferencesResponse>("conferences" + queryString.ToUriComponent())).Conferences);
        }
Exemplo n.º 4
0
        private Expression SerializeValue(object value, Property property, FilterOperator op)
        {
            var serialized = SearchFilter.GetValue(property, op, value);

            return(Expression.Constant(serialized));
        }