linq2codedom /LinqToCodedomProject/LinqToCodedom/Generator/Statements/using.cs

Language C# Lines 65
MD5 Hash d32124234eee633ef1688338fcc98cee Estimated Cost $1,359 (why?)
Repository https://linq2codedom.svn.codeplex.com/svn View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.CodeDom;
using LinqToCodedom.Visitors;
using LinqToCodedom.CodeDomPatterns;

namespace LinqToCodedom.Generator
{
    public static partial class Emit
    {
        public static CodeUsingStatement @using<TResult, T>(Expression<Func<TResult, T>> exp,
            params CodeStatement[] stmt)
        {
            return new CodeUsingStatement(
                new CodeExpressionVisitor(new VisitorContext()).Visit(exp), stmt
            );
        }

        public static CodeUsingStatement @using<TResult>(Expression<Func<TResult>> exp,
            params CodeStatement[] stmt)
        {
            return new CodeUsingStatement(
                new CodeExpressionVisitor(new VisitorContext()).Visit(exp), stmt
            );
        }

        public static CodeUsingStatement @using<TResult, T>(string varName, 
            Expression<Func<TResult, T>> exp, params CodeStatement[] stmt)
        {
            return new CodeUsingStatement(
                new CodeAssignExpression(
                    new CodeParameterDeclarationExpression(typeof(TResult), varName),
                    new CodeExpressionVisitor(new VisitorContext()).Visit(exp)
                ), stmt
            );
        }

        public static CodeUsingStatement @using<TResult>(string varName, 
            Expression<Func<TResult>> exp, params CodeStatement[] stmt)
        {
            return new CodeUsingStatement(
                new CodeAssignExpression(
                    new CodeParameterDeclarationExpression(typeof(TResult), varName),
                    new CodeExpressionVisitor(new VisitorContext()).Visit(exp)
                ), stmt
            );
        }

        public static CodeUsingStatement @using<TResult>(CodeTypeReference varType, string varName,
            Expression<Func<TResult>> exp, params CodeStatement[] stmt)
        {
            return new CodeUsingStatement(
                new CodeAssignExpression(
                    new CodeParameterDeclarationExpression(varType, varName),
                    new CodeExpressionVisitor(new VisitorContext()).Visit(exp)
                ), stmt
            );
        }

    }
}
Back to Top