Exemplo n.º 1
0
        internal static TravelDataResult FilterFunc(FilterRoot rootObj)
        {
            dynamic data = new ExpandoObject();

            data.countries       = rootObj.data.filter.countries as IList <Country2>;
            data.departureCities = rootObj.data.filter.departureCities as IList <ViewModels.DepartureCity>;

            var resultObj = new TravelDataResult()
            {
                success             = rootObj.success,
                elapsedMilliseconds = rootObj.elapsedMilliseconds,

                data = new
                {
                    countries       = rootObj.data.filter.countries as IList <Country2>,
                    departureCities = rootObj.data.filter.departureCities as IList <ViewModels.DepartureCity>
                }
            };

            return(resultObj);
        }
Exemplo n.º 2
0
        protected internal override Expression ToExpression(Expression expression)
        {
            Type collectionType = expression.Type;
            ParameterExpression collectionParameter = Expression.Parameter(collectionType);
            Expression          filterExpression    = FilterRoot.ToExpression(collectionParameter);

            Type itemType = EnumerableExtensions.GetItemType(collectionType);
            ParameterExpression itemParameter      = Expression.Parameter(itemType);
            Expression          selectorExpression = itemParameter;

            foreach (JsonPathNode node in Nodes)
            {
                selectorExpression = node.ToExpression(selectorExpression);
            }

            LambdaExpression selectorLambda = Expression.Lambda(selectorExpression, itemParameter);
            MethodInfo       methodSelect   = methodDefinitionSelect.MakeGenericMethod(itemType, selectorExpression.Type);

            expression = Expression.Call(methodSelect, filterExpression, selectorLambda);

            return(base.ToExpression(expression));
        }