Ejemplo n.º 1
0
        public static IEnumerable <LoopItem <TModel, TData> > Loop <TModel, TData>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, IEnumerable <TData> > > listExpression)
        {
            var enumerable = listExpression.Compile().Invoke(htmlHelper.ViewData.Model);
            var listFunc   = LoopItem <TModel, TData> .GetCurrentIndexedExpressionWithIntParam(listExpression).Compile();

            return(LoopItem <TModel, TData> .LoopItems(htmlHelper, listExpression, listFunc, enumerable));
        }
Ejemplo n.º 2
0
        public IEnumerable <LoopItem <TModel, TData> > Loop <TData>(Expression <Func <T, IEnumerable <TData> > > listExpression)
        {
            var newExpression = CombineExpression(listExpression);

            var compiledFunc2 = (Tuple <Func <T, IEnumerable <TData> >, Func <TModel, int, TData> >)cache.GetOrAdd(typeof(TData), y =>
            {
                var accessor = GetCurrentIndexedExpressionWithIntParam(newExpression).Compile();
                var tuple    = new Tuple <Func <T, IEnumerable <TData> >, Func <TModel, int, TData> >(listExpression.Compile(), accessor);
                return(tuple);
            });

            var enumerable = compiledFunc2.Item1(_listFunc.Invoke(_htmlHelper.ViewData.Model, Info.Index));

            return(LoopItem <TModel, TData> .LoopItems(_htmlHelper, newExpression, compiledFunc2.Item2, enumerable));
        }