Skip to content

Commit f2eeb8e

Browse files
author
zzzprojects
committed
Update docs2
Update docs2
1 parent f7e6dcf commit f2eeb8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+676
-676
lines changed

docs2/pages/api/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: API
44
permalink: api
55
---
66

7-
{% include template-h1.html %}
7+
88

99
## API
1010

docs2/pages/api/compile-execute.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Compile and execute a C# expression at runtime.
55
permalink: compile-execute
66
---
77

8-
{% include template-h1.html %}
8+
99

1010
## Description
1111
{{ page.description }}
@@ -21,15 +21,15 @@ Execute a C# expression and return the result:
2121
- Execute(string code, params object[] parameters)
2222

2323
### Example
24-
{% highlight csharp %}
24+
```csharp
2525
// using Z.Expressions; // Don't forget to include this.
2626
2727
var context = new EvalContext();
2828
// ... context options ...
2929
3030
string code = "Price * Quantity";
3131
var price = context.Execute<decimal>(code, orderItem);
32-
{% endhighlight %}
32+
```
3333
{% include component-try-it.html href='https://dotnetfiddle.net/tzBdMI' %}
3434

3535
## Compile
@@ -46,7 +46,7 @@ Compile a C# expression and return a delegate:
4646
- Compile(string, IDictionary&lt;string, Type&gt;): **Func&lt;IDictionary, object&gt;**
4747

4848
### Example
49-
{% highlight csharp %}
49+
```csharp
5050
// using Z.Expressions; // Don't forget to include this.
5151
5252
var context = new EvalContext();
@@ -60,5 +60,5 @@ foreach(var item in list)
6060
{
6161
totals += compiled(item);
6262
}
63-
{% endhighlight %}
63+
```
6464
{% include component-try-it.html href='https://dotnetfiddle.net/00YSGK' %}

docs2/pages/api/eval-compile.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Compile a C# expression and return a delegate.
55
permalink: eval-compile
66
---
77

8-
{% include template-h1.html %}
8+
99

1010
## Description
1111
{{ page.description }}
@@ -20,7 +20,7 @@ You can return the delegate as a strongly typed function or action:
2020
- Eval.Compile&lt;TDelegate&gt;(string code, params string[] parameterNames)
2121

2222
### Example
23-
{% highlight csharp %}
23+
```csharp
2424
// Delegate Func
2525
var compiled = Eval.Compile<Func<int, int, int>>("{0} + {1}");
2626
int result = compiled(1, 2);
@@ -32,7 +32,7 @@ compiled(1, 2);
3232
// Named Parameter
3333
var compiled = Eval.Compile<Func<int, int, int>>("X + Y", "X", "Y");
3434
int result = compiled(1, 2);
35-
{% endhighlight %}
35+
```
3636
{% include component-try-it.html href='https://dotnetfiddle.net/MBHlX8' %}
3737

3838
## Compile and return a delegate
@@ -46,7 +46,7 @@ You can return the delegate as a generic delegate:
4646
- Eval.Compile(string code, IDictionary&lt;string, Type&gt; nameTypes): Func&lt;IDictionary, object&gt;
4747

4848
### Example
49-
{% highlight csharp %}
49+
```csharp
5050
// Overload: Up to 9 parameters can be used
5151
var compiled = Eval.Compile("{0} + {1}", typeof(int), typeof(int));
5252
object result = compiled(1, 2);
@@ -64,7 +64,7 @@ var types = values.ToDictionary(x => x.Key, x => x.Value.GetType());
6464

6565
var compiled = Eval.Compile("X + Y", types);
6666
var result = compiled(values);
67-
{% endhighlight %}
67+
```
6868
{% include component-try-it.html href='https://dotnetfiddle.net/870F71' %}
6969

7070

docs2/pages/api/eval-execute.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Execute a C# expression and return the result.
55
permalink: eval-execute
66
---
77

8-
{% include template-h1.html %}
8+
99

1010
## Description
1111
{{ page.description }}
@@ -30,7 +30,7 @@ You can return the result as a strongly typed type:
3030

3131
### Example
3232

33-
{% highlight csharp %}
33+
```csharp
3434
// Parameter: Anonymous Type
3535
int result = Eval.Execute<int>("X + Y", new { X = 1, Y = 2} );
3636

@@ -46,7 +46,7 @@ int result = Eval.Execute<int>("X + Y", expandoObject);
4646
// Parameter: Dictionary Key
4747
var values = new Dictionary<string, object>() { {"X", 1}, {"Y", 2} };
4848
int result = Eval.Execute<int>("X + Y", values);
49-
{% endhighlight %}
49+
```
5050
{% include component-try-it.html href='https://dotnetfiddle.net/W9TwcP' %}
5151

5252
## Execute and return an object result
@@ -56,7 +56,7 @@ You can return the result as an object:
5656
- Eval.Execute(string code, object parameters)
5757
- Eval.Execute(string code, params object[] parameters)
5858

59-
{% highlight csharp %}
59+
```csharp
6060
// Parameter: Anonymous Type
6161
object result = Eval.Execute("X + Y", new { X = 1, Y = 2} );
6262

@@ -72,5 +72,5 @@ object result = Eval.Execute("X + Y", expandoObject);
7272
// Parameter: Dictionary Key
7373
var values = new Dictionary<string, object>() { {"X", 1}, {"Y", 2} };
7474
object result = Eval.Execute("X + Y", values);
75-
{% endhighlight %}
75+
```
7676
{% include component-try-it.html href='https://dotnetfiddle.net/8mtLH8' %}

docs2/pages/api/eval-manager.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Static manager class for options shared between all instances.
55
permalink: eval-manager
66
---
77

8-
{% include template-h1.html %}
8+
99

1010
## Description
1111
{{ page.description }}
@@ -14,10 +14,10 @@ permalink: eval-manager
1414
Gets or sets the cache to use to cache compiled delegate.
1515

1616
### Example
17-
{% highlight csharp %}
17+
```csharp
1818
// using Z.Expressions; // Don't forget to include this.
1919
EvalManager.Cache = MemoryCache.Default;
20-
{% endhighlight %}
20+
```
2121

2222
> You can use your own cache provider inheriting from System.Runtime.Caching.ObjectCache
2323
@@ -36,12 +36,12 @@ The default context is used in static methods:
3636
- [string".Compile](string-extensions#stringcompile)
3737

3838
### Example
39-
{% highlight csharp %}
39+
```csharp
4040
// using Z.Expressions; // Don't forget to include this.
4141
EvalManager.DefaultContext.RegisterExtensionMethod(typeof(Z.ExtensionMethods))
4242

4343
// Make member case insensitive (Math.pOW = Math.Pow)
4444
EvalManager.DefaultContext.BindingFlags = BindingFlags.IgnoreCase | context.BindingFlags
45-
{% endhighlight %}
45+
```
4646

4747

docs2/pages/api/linq-dynamic.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Extend the IEnumerable&lt;T&gt; and IQueryable&lt;T&gt; interface w
55
permalink: linq-dynamic
66
---
77

8-
{% include template-h1.html %}
8+
99

1010
## Description
1111
{{ page.description }}
@@ -34,12 +34,12 @@ You can use any LINQ method that support predicate with a dynamic C# expression
3434
- SingleOrDefault
3535

3636
### Example
37-
{% highlight csharp %}
37+
```csharp
3838
var list = new List<int>() { 1, 2, 3, 4, 5 };
3939

4040
var list2 = list.Where(x => "x > 2");
4141
var list3 = list.Where(x => "x > X", new { X = 2 }); // with parameter
42-
{% endhighlight %}
42+
```
4343
{% include component-try-it.html href='https://dotnetfiddle.net/S42mkU' %}
4444

4545
## LINQ Dynamic - Ordering and Selecting
@@ -55,7 +55,7 @@ You can use any ordering and selecting method with a dynamic C# expression:
5555
> The **"Dynamic"** suffix is required for not overriding the default behavior (ordering or selecting by a string is valid).
5656
5757
### Example
58-
{% highlight csharp %}
58+
```csharp
5959
var list = new List<int>() { 5, 2, 4, 1, 3 };
6060

6161
// SelectDynamic
@@ -65,7 +65,7 @@ var list3 = list.SelectDynamic(x => "new { y = x + 1 }", new { y = 1 });
6565
// OrderByDynamic
6666
var list4 = list.OrderByDynamic(x => "x + 1");
6767
var list5 = list.OrderByDynamic(x => "x + Y", new { Y = 1 });
68-
{% endhighlight %}
68+
```
6969

7070
## LINQ Dynamic - Execute
7171
You can push the LINQ Dynamic experience further by using the Execute method and chaining anything else:
@@ -74,9 +74,9 @@ You can push the LINQ Dynamic experience further by using the Execute method and
7474
- Execute&lt;TResult&gt;
7575

7676
### Example
77-
{% highlight csharp %}
77+
```csharp
7878
var list = new List<int>() { 1, 2, 3, 4, 5 };
7979

8080
var list2 = list.Execute<List<int>>("Where(x => x > 2).OrderBy(x => x).ToList()");
8181
var list3 = list.Execute<List<int>>("Where(x => x > y).OrderBy(x => x).ToList()", new { y = 2 });
82-
{% endhighlight %}
82+
```

docs2/pages/api/options.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Options to customize the context under which the C# expression is c
55
permalink: options
66
---
77

8-
{% include template-h1.html %}
8+
99

1010
## Description
1111
{{ page.description }}
@@ -14,25 +14,25 @@ permalink: options
1414
Gets or sets the value of the BindingFlags to use to retrieve member (Constructor, Method, Property, and Field)
1515

1616
### Example
17-
{% highlight csharp %}
17+
```csharp
1818
// using Z.Expressions; // Don't forget to include this.
1919
var context = new EvalContext();
2020

2121
// Make member case insensitive (Math.pOW = Math.Pow)
2222
context.BindingFlags = BindingFlags.IgnoreCase | context.BindingFlags
23-
{% endhighlight %}
23+
```
2424

2525
## CacheKeyPrefix
2626
Gets or sets the can key prefix to use to cache compiled delegate in the memory.
2727

2828
> We recommend always to use a different cache key prefix if you modify the options.
2929

3030
### Example
31-
{% highlight csharp %}
31+
```csharp
3232
// using Z.Expressions; // Don't forget to include this.
3333
var context = new EvalContext();
3434
context.CacheKey = Guid.NewGuid().ToString();
35-
{% endhighlight %}
35+
```
3636

3737
## IncludeMemberFromAllParameters
3838
Gets or sets if all members should be included from all parameters.
@@ -42,33 +42,33 @@ By default, member are only included when one parameter is specified.
4242
> This configuration can be very useful to disable if you execute multiple expression only once, and you believe they will never be re-used.
4343
4444
### Example
45-
{% highlight csharp %}
45+
```csharp
4646
// using Z.Expressions; // Don't forget to include this.
4747
var context = new EvalContext();
4848
context.IncludeMemberFromAllParameters = true;
4949

5050
Eval.Execute<bool>("catPropertyName == dogPropertyName", cat, dog);
51-
{% endhighlight %}
51+
```
5252

5353
## UseCache
5454
Gets or sets if compiled delegate shoud be cached in the memory or not.
5555

5656
> This configuration can be very useful to disable if you execute multiple expression only once, and you believe they will never be re-used.
5757
5858
### Example
59-
{% highlight csharp %}
59+
```csharp
6060
// using Z.Expressions; // Don't forget to include this.
6161
var context = new EvalContext();
6262
context.UseCache = false;
63-
{% endhighlight %}
63+
```
6464

6565
## UseCaretForExponent
6666
Gets or sets if the default behavior for the XOR operator '^' must act like an exponent operator instead.
6767

6868
> A new operator '^|' is available for the bitwise exclusive-OR operator.
6969
7070
### Example
71-
{% highlight csharp %}
71+
```csharp
7272
// using Z.Expressions; // Don't forget to include this.
7373
var context = new EvalContext() { UseCache = false };
7474

@@ -78,15 +78,15 @@ context.UseCaretForExponent = true;
7878
var exponentValue = = context.Eval("2^3"); // return 8;
7979
8080
var newExlusiveOrValue = = context.Eval("2^|3"); // return 1;
81-
{% endhighlight %}
81+
```
8282

8383
## Clone
8484
Create a new a shallow copy of the current EvalContext
8585

8686
> Cloning the EvalContext can be useful to copy all options including all types already registered to use it to change only what's required for the expression to evaluate.
8787
8888
### Example
89-
{% highlight csharp %}
89+
```csharp
9090
// using Z.Expressions; // Don't forget to include this.
9191
var context = EvalManager.DefaultContext.Clone();
92-
{% endhighlight %}
92+
```

docs2/pages/api/register-unregister.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Register and unregister assembly, constant, method, type, and more.
55
permalink: register-unregister
66
---
77

8-
{% include template-h1.html %}
8+
99

1010
## Description
1111
{{ page.description }}
@@ -27,7 +27,7 @@ You can register:
2727
- RegisterType(param Type[])
2828

2929
### Example
30-
{% highlight csharp %}
30+
```csharp
3131
// using Z.Expressions; // Don't forget to include this.
3232
var context = new EvalContext();
3333
context.RegisterAlias("Math2", "System.Math");
@@ -40,19 +40,19 @@ context.RegisterGlobalVariable("sessionCount", 0);
4040
context.RegisterStaticMember(typeof(Math), typeof(Int));
4141
context.RegisterStaticMember(powMemberInfo, RoundMemberInfo);
4242
context.RegisterType(typeof (bool), typeof(char);
43-
{% endhighlight %}
43+
```
4444

4545
### Static Member
4646
You can use static member name without qualifying them with their namespace or type name. Static member is a new feature in C# 6.0.
4747

48-
{% highlight csharp %}
48+
```csharp
4949
// using Z.Expressions; // Don't forget to include this.
5050
var context = new EvalContext();
5151
context.RegisterStaticMember(typeof(Math), typeof(Int));
5252

5353
bool result = context.Execute<double>("Pow(2, 3)"); // Math.Pow(2, 3) = 8"
5454
int result = context.Execute<int>("MinValue"); // Int.MinValue
55-
{% endhighlight %}
55+
```
5656

5757
## Unregister
5858
### Problem
@@ -70,7 +70,7 @@ You can unregister:
7070
- UnregisterType(param Type[])
7171

7272
### Example
73-
{% highlight csharp %}
73+
```csharp
7474
// using Z.Expressions; // Don't forget to include this.
7575
var context = new EvalContext();
7676
context.UnregisterAlias("Math2");
@@ -83,4 +83,4 @@ context.UnregisterGlobalVariables("sessionCount");
8383
context.UnregisterStaticMember(typeof(Math), typeof(Int));
8484
context.UnregisterStaticMember(powMemberInfo, RoundMemberInfo);
8585
context.UnregisterType(typeof (bool), typeof(char);
86-
{% endhighlight %}
86+
```

0 commit comments

Comments
 (0)