Skip to content

Commit d55789f

Browse files
Update compile-execute.md
1 parent fe9f388 commit d55789f

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

docs/pages/api/compile-execute.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
---
22
layout: default
33
title: Compile & Execute
4+
description: Compile and execute a C# expression at runtime.
45
permalink: compile-execute
56
---
67

78
{% include template-h1.html %}
89

9-
## Introduction
10-
11-
The EvalContext allow specifying customer configuration for evaluating, compiling and executing C# code and expression at runtime.
10+
## Description
11+
{{ page.description }}
1212

1313
## Execute
14-
### Problem
15-
You need to evaluate a dynamic C# code in an instance context.
14+
Execute a C# expression and return the result:
1615

17-
### Solution
18-
Create a new instance of EvalContext and use Execute method:
1916
- Execute<TResult>(string code)
2017
- Execute<TResult>(string code, object parameters)
2118
- Execute<TResult>(string code, params object[] parameters)
@@ -24,22 +21,19 @@ Create a new instance of EvalContext and use Execute method:
2421
- Execute(string code, params object[] parameters)
2522

2623
### Example
27-
```csharp
24+
{% highlight csharp %}
2825
// using Z.Expressions; // Don't forget to include this.
2926

3027
var context = new EvalContext();
3128
// ... context options ...
3229

3330
string code = "Price * Quantity";
3431
var price = context.Execute<decimal>(code, orderItem);
35-
```
32+
{% endhighlight %}
3633

3734
## Compile
38-
### Problem
39-
You need to compile a dynamic C# code in an instance context.
35+
Compile a C# expression and return a delegate:
4036

41-
### Solution
42-
Create a new instance of EvalContext and use Compile method:
4337
- Compile&lt;TDelegate&gt;(string code)
4438
- Compile&lt;TDelegate&gt;(string code, IEnumerable&lt;string&gt; parameterNames)
4539
- Compile&lt;TDelegate&gt;(string code, params string[] parameterNames)
@@ -51,7 +45,7 @@ Create a new instance of EvalContext and use Compile method:
5145
- Compile(string, IDictionary&lt;string, Type&gt;): **Func&lt;IDictionary, object&gt;**
5246

5347
### Example
54-
```csharp
48+
{% highlight csharp %}
5549
// using Z.Expressions; // Don't forget to include this.
5650

5751
var context = new EvalContext();
@@ -65,4 +59,4 @@ foreach(var item in list)
6559
{
6660
totals += compiled(item);
6761
}
68-
```
62+
{% endhighlight %}

0 commit comments

Comments
 (0)