コード例 #1
0
        public override AstNode VisitUsingStatement(UsingStatement usingStatement)
        {
            var awaitSearch = new AwaitSearchVisitor(null);

            usingStatement.AcceptVisitor(awaitSearch);

            var            awaiters = awaitSearch.GetAwaitExpressions().ToArray();
            UsingStatement node     = (UsingStatement)base.VisitUsingStatement(usingStatement) ?? (UsingStatement)usingStatement.Clone();

            if (awaiters.Length > 0)
            {
                IEnumerable <AstNode> inner = null;

                var res     = node.ResourceAcquisition;
                var varStat = res as VariableDeclarationStatement;
                if (varStat != null)
                {
                    inner = varStat.Variables.Skip(1);
                    res   = varStat.Variables.First();
                }

                return(EmitUsing(node, res, inner, varStat));
            }

            return(node);
        }
コード例 #2
0
        protected AstNode[] GetAwaiters(AstNode node)
        {
            var awaitSearch = new AwaitSearchVisitor(Emitter);

            node.AcceptVisitor(awaitSearch);

            return(awaitSearch.GetAwaitExpressions().ToArray());
        }
コード例 #3
0
        public override void VisitUsingStatement(UsingStatement usingStatement)
        {
            if (Found)
            {
                return;
            }

            var awaitSearch = new AwaitSearchVisitor(null);

            usingStatement.AcceptVisitor(awaitSearch);

            var awaiters = awaitSearch.GetAwaitExpressions().ToArray();

            if (awaiters.Length > 0)
            {
                Found = true;
            }

            base.VisitUsingStatement(usingStatement);
        }