protected override Expression VisitMethodCall(MethodCallExpression m)
 {
     if (!_scopeFound)
     {
         if (m.IsContentIndexer())
         {
             _currentScopeIndexer = m;
             var finder = new ScopedForEachFinder();
             Expression rewrittenIndexerChild = finder.FindIterator(m.Arguments[0]);
             if (finder.Iterator != null)
             {
                 _scopeFound = true;
                 ScopeToRewrite = _currentScopeIndexer;
                 HtmlBuilder = rewrittenIndexerChild;
                 Iterator = finder.Iterator;
             }
         }
     }
     return base.VisitMethodCall(m);
 }
Ejemplo n.º 2
0
 protected override Expression VisitMethodCall(MethodCallExpression m)
 {
     if (!_scopeFound)
     {
         if (m.IsContentIndexer())
         {
             _currentScopeIndexer = m;
             var        finder = new ScopedForEachFinder();
             Expression rewrittenIndexerChild = finder.FindIterator(m.Arguments[0]);
             if (finder.Iterator != null)
             {
                 _scopeFound    = true;
                 ScopeToRewrite = _currentScopeIndexer;
                 HtmlBuilder    = rewrittenIndexerChild;
                 Iterator       = finder.Iterator;
             }
         }
     }
     return(base.VisitMethodCall(m));
 }
        public static Expression<Func<IElement>> ApplySharpView(this Expression<Func<IElement>> expression)
        {
            int scopeLevel = 0;
            Expression<Func<IElement>> rewrittenExpression = new ScopedForEachFinder(scopeLevel).RewriteRoot(expression);

            ChildScopeForEachFinder childScopeFinder;
            while ((childScopeFinder = new ChildScopeForEachFinder()).FindNextScopeForRewriting(rewrittenExpression))
            {
                rewrittenExpression = (Expression<Func<IElement>>)
                                      new ChildScopeRewriterVisitor(scopeLevel,
                                                                    childScopeFinder.ScopeToRewrite,
                                                                    childScopeFinder.Iterator,
                                                                    childScopeFinder.HtmlBuilder).
                                          RewriteScopeToMethodCall(rewrittenExpression);
                scopeLevel++;
            }

            return
                (Expression<Func<IElement>>)
                new IfRewriterVisitor().Rewrite(new SelectHtmlPropertyPathRewriter().Rewrite(rewrittenExpression));
        }
Ejemplo n.º 4
0
        public static Expression <Func <IElement> > ApplySharpView(this Expression <Func <IElement> > expression)
        {
            int scopeLevel = 0;
            Expression <Func <IElement> > rewrittenExpression = new ScopedForEachFinder(scopeLevel).RewriteRoot(expression);

            ChildScopeForEachFinder childScopeFinder;

            while ((childScopeFinder = new ChildScopeForEachFinder()).FindNextScopeForRewriting(rewrittenExpression))
            {
                rewrittenExpression = (Expression <Func <IElement> >)
                                      new ChildScopeRewriterVisitor(scopeLevel,
                                                                    childScopeFinder.ScopeToRewrite,
                                                                    childScopeFinder.Iterator,
                                                                    childScopeFinder.HtmlBuilder).
                                      RewriteScopeToMethodCall(rewrittenExpression);
                scopeLevel++;
            }

            return
                ((Expression <Func <IElement> >)
                 new IfRewriterVisitor().Rewrite(new SelectHtmlPropertyPathRewriter().Rewrite(rewrittenExpression)));
        }