Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

.NET wrapper for working with the JavaScript engines of Internet Explorer and Edge Legacy.

License

NotificationsYou must be signed in to change notification settings

Taritsyn/MsieJavaScriptEngine

Repository files navigation

MSIE JS Engine Logo

This project is a .NET wrapper for working with the JavaScript engines of Internet Explorer and Edge Legacy (JsRT versions of Chakra, ActiveScript version of Chakra and Classic JavaScript Engine).Project was based on the code ofSassAndCoffee.JavaScript,Chakra Sample Hosts andjsrt-dotnet.

MSIE JavaScript Engine requires a installation of Internet Explorer or Edge Legacy on the machine and can work in 5 modes, that are defined in theJsEngineMode enumeration:

  • Auto. Automatically selects the most modern JavaScript engine from available on the machine.
  • 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.Not supported in version for .NET Core.
  • ChakraActiveScript. ActiveScript version of Chakra JavaScript engine (supports ECMAScript 5). Requires Internet Explorer 9 or higher on the machine.Not supported in version for .NET Core.
  • ChakraIeJsRt. “IE” JsRT version of Chakra JavaScript engine (supports ECMAScript 5). Requires Internet Explorer 11 or Microsoft Edge Legacy on the machine.
  • ChakraEdgeJsRt. “Edge” JsRT version of Chakra JavaScript engine (supports ECMAScript 5). Requires Microsoft Edge Legacy on the machine.

The supported .NET types are as follows:

  • MsieJavaScriptEngine.Undefined
  • System.Boolean
  • System.Int32
  • System.Double
  • System.String

Installation

This library can be installed through NuGet -https://www.nuget.org/packages/MsieJavaScriptEngine.

Usage

Consider a simple example of usage of the MSIE JavaScript Engine:

usingSystem;usingMsieJavaScriptEngine;usingMsieJavaScriptEngine.Helpers;namespaceMsieJavaScriptEngine.Example.Console{classProgram{staticvoidMain(string[]args){try{using(varjsEngine=newMsieJsEngine()){conststringexpression="7 * 8 - 20";varresult=jsEngine.Evaluate<int>(expression);Console.WriteLine("{0} = {1}",expression,result);}}catch(JsEngineLoadExceptione){Console.WriteLine("During loading of JavaScript engine an error occurred.");Console.WriteLine();Console.WriteLine(JsErrorHelpers.GenerateErrorDetails(e));}catch(JsScriptExceptione){Console.WriteLine("During processing of JavaScript code an error occurred.");Console.WriteLine();Console.WriteLine(JsErrorHelpers.GenerateErrorDetails(e));}catch(JsExceptione){Console.WriteLine("During working of JavaScript engine an unknown error occurred.");Console.WriteLine();Console.WriteLine(JsErrorHelpers.GenerateErrorDetails(e));}Console.ReadLine();}}}

First we create an instance of theMsieJsEngine class.Then we evaluate a JavaScript expression by using of theEvaluate method and output its result to the console.In addition, we provide handling of the following exception types:JsEngineLoadException,JsScriptException andJsException.In the MSIE JavaScript Engine, exceptions have the following hierarchy:

  • JsException
    • JsEngineException
      • JsEngineLoadException
    • JsFatalException
    • JsScriptException
      • JsCompilationException
      • JsRuntimeException
        • JsInterruptedException
    • JsUsageException

Also, when you create an instance of theMsieJsEngine class, then you can pass the JavaScript engine settings via the constructor.Consider in detail properties of theJsEngineSettings class:

Property nameData typeDefault valueDescription
AllowReflectionBooleanfalse

Flag for whether to allow the usage of reflection API in the script code.

This affectsObject.GetType,Exception.GetType,Exception.TargetSite andDelegate.Method.

EnableDebuggingBooleanfalseFlag for whether to allow debugging in Visual Studio by adding thedebugger statement to script code.
EngineModeJsEngineMode enumerationAutoJavaScript engine mode.
MaxStackSizeInt32503 808 or1 007 616

Maximum stack size in bytes.

Set a0 to use the default maximum stack size specified in the header for the executable.

UseEcmaScript5PolyfillBooleanfalseFlag for whether to use the ECMAScript 5 Polyfill.
UseJson2LibraryBooleanfalseFlag for whether to use theJSON2 library

Release History

See thechangelog.

License

Apache License Version 2.0

Credits

Who's Using MSIE JavaScript Engine

If you use the MSIE JavaScript Engine in some project, please send me a message so I can include it in this list:

About

.NET wrapper for working with the JavaScript engines of Internet Explorer and Edge Legacy.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp