You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+70-46Lines changed: 70 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,12 @@ MSIE JavaScript Engine for .NET
6
6
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).
7
7
Project was based on the code of [SassAndCoffee.JavaScript](http://github.com/paulcbetts/SassAndCoffee) and [Chakra Sample Hosts](http://github.com/panopticoncentral/chakra-host).
8
8
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 <codetitle="MsieJavaScriptEngine.JsEngineMode">JsEngineMode</code> enumeration:
10
10
11
11
*`Auto`. Automatically selects the most modern JavaScript engine from available on the machine.
12
12
*`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.
13
13
*`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.
15
15
*`ChakraEdgeJsRt`. “Edge” JsRT version of Chakra JavaScript engine (supports ECMAScript 5). Requires Microsoft Edge on the machine.
16
16
17
17
The supported .NET types are as follows:
@@ -28,61 +28,85 @@ This library can be installed through NuGet - [http://nuget.org/packages/MsieJav
28
28
## Usage
29
29
Consider a simple example of usage of the MSIE JavaScript Engine:
30
30
31
-
namespace MsieJavaScriptEngine.Example.Console
32
-
{
33
-
using System;
31
+
```csharp
32
+
namespaceMsieJavaScriptEngine.Example.Console
33
+
{
34
+
usingSystem;
34
35
35
-
using MsieJavaScriptEngine;
36
-
using MsieJavaScriptEngine.Helpers;
36
+
usingMsieJavaScriptEngine;
37
+
usingMsieJavaScriptEngine.Helpers;
37
38
38
-
class Program
39
+
classProgram
40
+
{
41
+
staticvoidMain(string[] args)
39
42
{
40
-
static void Main(string[] args)
43
+
try
41
44
{
42
-
try
43
-
{
44
-
using (var jsEngine = new MsieJsEngine(new JsEngineSettings
Console.WriteLine("During loading of JavaScript engine an error occurred.");
56
+
Console.WriteLine();
57
+
Console.WriteLine(JsErrorHelpers.Format(e));
58
+
}
59
+
catch (JsRuntimeExceptione)
60
+
{
61
+
Console.WriteLine("During execution of JavaScript code an error occurred.");
62
+
Console.WriteLine();
63
+
Console.WriteLine(JsErrorHelpers.Format(e));
64
+
}
65
+
66
+
Console.ReadLine();
72
67
}
73
68
}
69
+
}
70
+
```
74
71
75
-
First we create an instance of the `MsieJsEngine` class and pass the following parameters to the constructor:
76
-
77
-
1.`engineMode` - JavaScript engine mode;
78
-
2.`useEcmaScript5Polyfill` - flag for whether to use the ECMAScript 5 Polyfill;
79
-
3.`useJson2Library` - flag for whether to use the [JSON2](http://github.com/douglascrockford/JSON-js) library.
80
-
81
-
The values of constructor parameters in the above code correspond to the default values.
82
-
72
+
First we create an instance of the <codetitle="MsieJavaScriptEngine.MsieJsEngine">MsieJsEngine</code> class.
83
73
Then we evaluate a JavaScript expression by using of the `Evaluate` method and output its result to the console.
74
+
In addition, we provide handling of the following exception types: <codetitle="MsieJavaScriptEngine.JsEngineLoadException">JsEngineLoadException</code> and <codetitle="MsieJavaScriptEngine.JsRuntimeException">JsRuntimeException</code>.
75
+
76
+
Also, when you create an instance of the <codetitle="MsieJavaScriptEngine.MsieJsEngine">MsieJsEngine</code> class, then you can pass the JavaScript engine settings via the constructor.
77
+
Consider in detail properties of the <codetitle="MsieJavaScriptEngine.JsEngineSettings">JsEngineSettings</code> class:
<td>Flag for whether to use the <a href="http://github.com/douglascrockford/JSON-js">JSON2</a> library</td>
106
+
</tr>
107
+
</tbody>
108
+
</table>
84
109
85
-
In addition, we provide handling of the following exception types: `JsEngineLoadException` and `JsRuntimeException`.
86
110
87
111
## Release History
88
112
See the [changelog](CHANGELOG.md).
@@ -92,7 +116,7 @@ See the [changelog](CHANGELOG.md).
92
116
93
117
## Credits
94
118
*[SassAndCoffee.JavaScript](http://github.com/xpaulbettsx/SassAndCoffee) - [License: Microsoft Public License (Ms-PL)](http://github.com/paulcbetts/SassAndCoffee/blob/master/COPYING) Part of the code of this library served as the basis for the ActiveScript version of Chakra and Classic JavaScript Engine.
95
-
*[Chakra Sample Hosts](http://github.com/panopticoncentral/chakra-host) - [License: Apache License 2.0 (Apache)](http://github.com/panopticoncentral/chakra-host/blob/master/LICENSE) C# example from this project served as the basis for the JsRT version of Chakra.
119
+
*[Chakra Sample Hosts](http://github.com/panopticoncentral/chakra-host) - [License: Apache License 2.0 (Apache)](http://github.com/panopticoncentral/chakra-host/blob/master/LICENSE) C# example from this project served as the basis for the JsRT versions of Chakra.
96
120
*[ECMAScript 5 Polyfill](http://nuget.org/packages/ES5) and [MDN JavaScript Polyfills](http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference) - Adds support for many of the new functions in ECMAScript 5 to downlevel browsers.
0 commit comments