Skip to content

Commit 52aefc2

Browse files
committed
README.md: Updated example of usage
1 parent de40351 commit 52aefc2

1 file changed

Lines changed: 70 additions & 46 deletions

File tree

‎README.md‎

Lines changed: 70 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ MSIE JavaScript Engine for .NET
66
This project is a .NET wrapper for working with the JavaScript engines of Internet Explorer and Edge (JsRT versions of Chakra, ActiveScript version of Chakra and Classic JavaScript Engine).
77
Project was based on the code of [SassAndCoffee.JavaScript](http://github.com/paulcbetts/SassAndCoffee) and [Chakra Sample Hosts](http://github.com/panopticoncentral/chakra-host).
88

9-
MSIE JavaScript Engine requires a installation of Internet Explorer or Edge on the machine and can work in 5 modes, that are defined in the `MsieJavaScriptEngine.JsEngineMode` enumeration:
9+
MSIE JavaScript Engine requires a installation of Internet Explorer or Edge on the machine and can work in 5 modes, that are defined in the <code title="MsieJavaScriptEngine.JsEngineMode">JsEngineMode</code> enumeration:
1010

1111
* `Auto`. Automatically selects the most modern JavaScript engine from available on the machine.
1212
* `Classic`. Classic MSIE JavaScript engine (supports ECMAScript 3 with possibility of using the ECMAScript 5 Polyfill and the JSON2 library). Requires Internet Explorer 6 or higher on the machine.
1313
* `ChakraActiveScript`. ActiveScript version of Chakra JavaScript engine (supports ECMAScript 5). Requires Internet Explorer 9 or higher on the machine.
14-
* `ChakraIeJsRt`. “Legacy” JsRT version of Chakra JavaScript engine (supports ECMAScript 5). Requires Internet Explorer 11 or higher on the machine.
14+
* `ChakraIeJsRt`. “IE” JsRT version of Chakra JavaScript engine (supports ECMAScript 5). Requires Internet Explorer 11 or Microsoft Edge on the machine.
1515
* `ChakraEdgeJsRt`. “Edge” JsRT version of Chakra JavaScript engine (supports ECMAScript 5). Requires Microsoft Edge on the machine.
1616

1717
The supported .NET types are as follows:
@@ -28,61 +28,85 @@ This library can be installed through NuGet - [http://nuget.org/packages/MsieJav
2828
## Usage
2929
Consider a simple example of usage of the MSIE JavaScript Engine:
3030

31-
namespace MsieJavaScriptEngine.Example.Console
32-
{
33-
using System;
31+
```csharp
32+
namespace MsieJavaScriptEngine.Example.Console
33+
{
34+
using System;
3435

35-
using MsieJavaScriptEngine;
36-
using MsieJavaScriptEngine.Helpers;
36+
using MsieJavaScriptEngine;
37+
using MsieJavaScriptEngine.Helpers;
3738

38-
class Program
39+
class Program
40+
{
41+
static void Main(string[] args)
3942
{
40-
static void Main(string[] args)
43+
try
4144
{
42-
try
43-
{
44-
using (var jsEngine = new MsieJsEngine(new JsEngineSettings
45-
{
46-
EngineMode = JsEngineMode.Auto,
47-
UseEcmaScript5Polyfill = false,
48-
UseJson2Library = false
49-
}))
50-
{
51-
const string expression = "7 * 8 - 20";
52-
var result = jsEngine.Evaluate<int>(expression);
53-
54-
Console.WriteLine("{0} = {1}", expression, result);
55-
}
56-
}
57-
catch (JsEngineLoadException e)