- 
                Notifications
    You must be signed in to change notification settings 
- Fork 49
Creating instances of JS engines
It is recommended create instances of JS engines by using the following methods of the IJsEngineSwitcher interface: CreateEngine and CreateDefaultEngine.
In this case, instances of JS engines are created with the settings, that you specified during their registration.
CreateEngine method takes only one parameter - name of JS engine:
IJsEngine engine = JsEngineSwitcher.Current.CreateEngine("ChakraCoreJsEngine");You can also use constant:
IJsEngine engine = JsEngineSwitcher.Current.CreateEngine(ChakraCoreJsEngine.EngineName);Since the name of JS engine is a string value, then you can get it from an external source (for example, configuration file). This feature allows you to quickly switch a whole project to usage of the different JS engine.
CreateDefaultEngine method takes no parameters:
IJsEngine engine = JsEngineSwitcher.Current.CreateDefaultEngine();Decision about which JS engine you need to create depends on the value of the DefaultEngineName property of the IJsEngineSwitcher interface.
You can also directly create instances of JS engines by using constructors:
IJsEngine engine = new ChakraCoreJsEngine(new ChakraCoreSettings
{
    DisableEval = true,
    EnableExperimentalFeatures = true
});But choosing this approach, you lose all benefits of the JavaScript Engine Switcher infrastructure.
- Registration of JS engines
- Creating instances of JS engines
- JS engines
- Upgrade guides
- Additional reading and resources