├── .gitignore
├── ExpressionBuilder
├── .nuget
│ ├── NuGet.Config
│ ├── NuGet.exe
│ └── NuGet.targets
├── ExpressionBuilder.Test
│ ├── AssertString.cs
│ ├── CallingGenericFunctionsInside.cs
│ ├── CodeLineTest.cs
│ ├── ExpressionBuilder.Test.csproj
│ ├── ExpressionUtilTest.cs
│ ├── FunctionTest.cs
│ ├── IfTest.cs
│ ├── OperationTest.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── StringOperationTest.cs
│ ├── ToDoTest.cs
│ ├── WhileTest.cs
│ └── packages.config
├── ExpressionBuilder.sln
├── ExpressionBuilder
│ ├── CodeLine.cs
│ ├── CodeLines
│ │ ├── Assign.cs
│ │ ├── CreateReturn.cs
│ │ ├── CreateVariable.cs
│ │ ├── Nop.cs
│ │ ├── OperationAction.cs
│ │ └── OperationInvoke.cs
│ ├── CollectionOperation.cs
│ ├── Condition.cs
│ ├── Conditions
│ │ ├── BinaryCondition.cs
│ │ └── MultiCondition.cs
│ ├── Enums
│ │ ├── AssignementOperators.cs
│ │ └── ComparaisonOperator.cs
│ ├── ExpressionBuilder.csproj
│ ├── ExpressionBuilder.nuspec
│ ├── Fluent
│ │ ├── IBodyOrParameter.cs
│ │ ├── ICodeLine.cs
│ │ ├── IElseIf.cs
│ │ ├── IExpressionResult.cs
│ │ ├── IFunctionBody.cs
│ │ ├── IFunctionParameter.cs
│ │ ├── IFunctionReturn.cs
│ │ ├── IIf.cs
│ │ ├── IIfThen.cs
│ │ ├── ILeftRightable.cs
│ │ ├── ILeftable.cs
│ │ ├── IOperation.cs
│ │ ├── IRightable.cs
│ │ └── IWhile.cs
│ ├── Function.cs
│ ├── If.cs
│ ├── Operation.cs
│ ├── Operations
│ │ ├── OperationCast.cs
│ │ ├── OperationConst.cs
│ │ ├── OperationFunc.cs
│ │ ├── OperationInvokeReturn.cs
│ │ ├── OperationNew.cs
│ │ ├── OperationNewArrayInit.cs
│ │ └── OperationVariable.cs
│ ├── Parser
│ │ ├── IParsable.cs
│ │ ├── ParseContext.cs
│ │ └── ParseLevel.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── StringOperation.cs
│ ├── TODO.txt
│ ├── Utils
│ │ ├── ExpressionUtil.cs
│ │ ├── LambdaPropertyDescriptor.cs
│ │ ├── MethodCallDescriptor.cs
│ │ ├── PropertyGetSet.cs
│ │ └── ReflectionUtil.cs
│ ├── Variable.cs
│ └── While.cs
└── build_utils
│ ├── BuildCleaner.exe
│ ├── CommentsHeader.exe
│ ├── GenericHelpers.dll
│ ├── Ionic.Zip.Reduced.dll
│ ├── README.md
│ ├── VisualStudioIdentifier.exe
│ ├── dobuild.bat
│ ├── dobuild_clean.bat
│ ├── dobuild_env.bat
│ ├── dobuild_env.template
│ ├── dobuild_nuget.bat
│ ├── dobuild_simple.bat
│ ├── dobuild_single.bat
│ ├── license.cs
│ ├── setcopyright.bat
│ ├── zipproject.bat
│ └── ziproject.nuget.bat
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | [Bb]in/
3 | [Oo]bj/
4 |
5 | # mstest test results
6 | TestResults
7 |
8 | ## Ignore Visual Studio temporary files, build results, and
9 | ## files generated by popular Visual Studio add-ons.
10 |
11 | # User-specific files
12 | *.suo
13 | *.user
14 | *.sln.docstates
15 | .opencover_bin
16 | .report
17 |
18 | # Build results
19 | tmp_nuget/
20 | [Dd]ebug/
21 | [Rr]elease/
22 | *_i.c
23 | *_p.c
24 | *.ilk
25 | *.meta
26 | *.obj
27 | *.pch
28 | *.pdb
29 | *.pgc
30 | *.pgd
31 | *.rsp
32 | *.sbr
33 | *.tlb
34 | *.tli
35 | *.tlh
36 | *.tmp
37 | *.log
38 | *.vspscc
39 | *.vssscc
40 | .builds
41 |
42 | # Visual C++ cache files
43 | ipch/
44 | *.aps
45 | *.ncb
46 | *.opensdf
47 | *.sdf
48 |
49 | # Visual Studio profiler
50 | *.psess
51 | *.vsp
52 | *.vspx
53 |
54 | # Guidance Automation Toolkit
55 | *.gpState
56 |
57 | # ReSharper is a .NET coding add-in
58 | _ReSharper*
59 |
60 | # NCrunch
61 | *.ncrunch*
62 | .*crunch*.local.xml
63 |
64 | # Installshield output folder
65 | [Ee]xpress
66 |
67 | # DocProject is a documentation generator add-in
68 | DocProject/buildhelp/
69 | DocProject/Help/*.HxT
70 | DocProject/Help/*.HxC
71 | DocProject/Help/*.hhc
72 | DocProject/Help/*.hhk
73 | DocProject/Help/*.hhp
74 | DocProject/Help/Html2
75 | DocProject/Help/html
76 |
77 | # Click-Once directory
78 | publish
79 |
80 | # Publish Web Output
81 | *.Publish.xml
82 |
83 | # NuGet Packages Directory
84 | packages/
85 | tmp_nuget/
86 | vs.bat
87 |
88 | # Windows Azure Build Output
89 | csx
90 | *.build.csdef
91 |
92 | # Windows Store app package directory
93 | AppPackages/
94 | .nodeCs
95 |
96 | # Others
97 | [Bb]in
98 | [Oo]bj
99 | sql
100 | TestResults
101 | [Tt]est[Rr]esult*
102 | *.Cache
103 | ClientBin
104 | [Ss]tyle[Cc]op.*
105 | ~$*
106 | *.dbmdl
107 | Generated_Code #added for RIA/Silverlight projects
108 |
109 | # Backup & report files from converting an old project file to a newer
110 | # Visual Studio version. Backup files are not needed, because we have git ;-)
111 | _UpgradeReport_Files/
112 | Backup*/
113 | UpgradeLog*.XML
114 |
115 | App_Bin/
116 | PerfMon/
117 |
--------------------------------------------------------------------------------
/ExpressionBuilder/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ExpressionBuilder/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kendarorg/ExpressionBuilder/b9dc4731934715cba4e217b56634c7ff6f8066a4/ExpressionBuilder/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/ExpressionBuilder/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 |
32 |
33 |
34 |
35 | $(SolutionDir).nuget
36 |
37 |
38 |
39 | packages.$(MSBuildProjectName.Replace(' ', '_')).config
40 |
41 |
42 |
43 |
44 |
45 | $(PackagesProjectConfig)
46 |
47 |
48 |
49 |
50 | packages.config
51 |
52 |
53 |
54 |
55 |
56 |
57 | $(NuGetToolsPath)\NuGet.exe
58 | @(PackageSource)
59 |
60 | "$(NuGetExePath)"
61 | mono --runtime=v4.0.30319 $(NuGetExePath)
62 |
63 | $(TargetDir.Trim('\\'))
64 |
65 | -RequireConsent
66 | -NonInteractive
67 |
68 | "$(SolutionDir) "
69 | "$(SolutionDir)"
70 |
71 |
72 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
73 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
74 |
75 |
76 |
77 | RestorePackages;
78 | $(BuildDependsOn);
79 |
80 |
81 |
82 |
83 | $(BuildDependsOn);
84 | BuildPackage;
85 |
86 |
87 |
88 |
89 |
90 |
91 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
113 |
115 |
116 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/ExpressionBuilder/ExpressionBuilder.Test/AssertString.cs:
--------------------------------------------------------------------------------
1 | // ===========================================================
2 | // Copyright (c) 2014-2015, Enrico Da Ros/kendar.org
3 | // All rights reserved.
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are met:
7 | //
8 | // * Redistributions of source code must retain the above copyright notice, this
9 | // list of conditions and the following disclaimer.
10 | //
11 | // * Redistributions in binary form must reproduce the above copyright notice,
12 | // this list of conditions and the following disclaimer in the documentation
13 | // and/or other materials provided with the distribution.
14 | //
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | // ===========================================================
26 |
27 |
28 | using System;
29 | using System.ComponentModel;
30 | using System.Text;
31 | using Microsoft.VisualStudio.TestTools.UnitTesting;
32 |
33 | namespace ExpressionBuilder.Test
34 | {
35 | public static class AssertString
36 | {
37 | public static void AreEqual(string expected, string actual)
38 | {
39 | expected = expected.Replace("\r\n", "\n");
40 | actual = actual.Replace("\r\n", "\n");
41 | if (expected.Length == actual.Length)
42 | {
43 | for (var i = 0; i < expected.Length; i++)
44 | {
45 | var expectedChar = (int) expected[i];
46 | var actualChar = (int)actual[i];
47 | if (actualChar != expectedChar)
48 | {
49 | break;
50 | }
51 | }
52 | return;
53 | }
54 | throw new AssertFailedException(string.Format("AssertString.AreEqual\nExpected <{0}>\nActual <{1}>", expected,
55 | actual));
56 | }
57 |
58 | public static string UTF8ToAscii(string text)
59 | {
60 | var utf8 = Encoding.UTF8;
61 | Byte[] encodedBytes = utf8.GetBytes(text);
62 | Byte[] convertedBytes = Encoding.Convert(Encoding.UTF8, Encoding.ASCII, encodedBytes);
63 |
64 | return Encoding.ASCII.GetString(convertedBytes);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/ExpressionBuilder/ExpressionBuilder.Test/CallingGenericFunctionsInside.cs:
--------------------------------------------------------------------------------
1 | // ===========================================================
2 | // Copyright (c) 2014-2015, Enrico Da Ros/kendar.org
3 | // All rights reserved.
4 | //
5 | // Redistribution and use in source and binary forms, with or without
6 | // modification, are permitted provided that the following conditions are met:
7 | //
8 | // * Redistributions of source code must retain the above copyright notice, this
9 | // list of conditions and the following disclaimer.
10 | //
11 | // * Redistributions in binary form must reproduce the above copyright notice,
12 | // this list of conditions and the following disclaimer in the documentation
13 | // and/or other materials provided with the distribution.
14 | //
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | // ===========================================================
26 |
27 |
28 | using System;
29 | using System.Collections.Generic;
30 | using System.Linq;
31 | using System.Text;
32 | using Microsoft.VisualStudio.TestTools.UnitTesting;
33 |
34 | namespace ExpressionBuilder.Test
35 | {
36 |
37 | [TestClass]
38 | public class CallingGenericFunctionsInside
39 | {
40 |
41 | [TestMethod]
42 | public void ShouldBePossibleToCallLambdaFunction()
43 | {
44 | const string expected =
45 | @"public System.String Call(System.String first, System.String second)
46 | {
47 | System.String result;
48 | result = System.Func(first, second);
49 | return result;
50 | }";
51 |
52 | var newExpression = Function.Create()
53 | .WithParameter("first")
54 | .WithParameter("second")
55 | .WithBody(
56 | CodeLine.CreateVariable("result"),
57 | CodeLine.Assign("result",
58 | Operation.Func