Exemple #1
0
        /// <summary>
        /// Adds a instance of <see cref="EFFCChakraCoreJsEngineFactory"/> to
        /// the specified <see cref="JsEngineFactoryCollection" />
        /// </summary>
        /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param>
        /// <param name="configure">The delegate to configure the provided <see cref="EFFCChakraCoreSettings"/></param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddEFFCChakraCore(this JsEngineFactoryCollection source,
                                                                  Action <EFFCChakraCoreSettings> configure)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (configure == null)
            {
                throw new ArgumentNullException("configure");
            }

            var settings = new EFFCChakraCoreSettings();

            configure(settings);

            return(source.AddEFFCChakraCore(settings));
        }
Exemple #2
0
        /// <summary>
        /// Constructs an instance of adapter for the ChakraCore JS engine
        /// </summary>
        /// <param name="settings">Settings of the ChakraCore JS engine</param>
        public EFFCChakraCoreJsEngine(EFFCChakraCoreSettings settings)
        {
            EFFCChakraCoreSettings chakraCoreSettings = settings ?? new EFFCChakraCoreSettings();

            JsRuntimeAttributes attributes = JsRuntimeAttributes.None;

            if (chakraCoreSettings.DisableBackgroundWork)
            {
                attributes |= JsRuntimeAttributes.DisableBackgroundWork;
            }
            if (chakraCoreSettings.DisableNativeCodeGeneration)
            {
                attributes |= JsRuntimeAttributes.DisableNativeCodeGeneration;
            }
            if (chakraCoreSettings.DisableEval)
            {
                attributes |= JsRuntimeAttributes.DisableEval;
            }
            if (chakraCoreSettings.EnableExperimentalFeatures)
            {
                attributes |= JsRuntimeAttributes.EnableExperimentalFeatures;
            }

            _externalObjectFinalizeCallback = ExternalObjectFinalizeCallback;

            _dispatcher.Invoke(() =>
            {
                try
                {
                    _jsRuntime = JsRuntime.Create(attributes, null);
                    _jsContext = _jsRuntime.CreateContext();
                }
                catch (Exception e)
                {
                    throw new JsEngineLoadException(
                        string.Format(CoreStrings.Runtime_JsEngineNotLoaded,
                                      EngineName, e.Message), EngineName, EngineVersion, e);
                }
            });
        }
Exemple #3
0
        /// <summary>
        /// Adds a instance of <see cref="EFFCChakraCoreJsEngineFactory"/> to
        /// the specified <see cref="JsEngineFactoryCollection" />
        /// </summary>
        /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param>
        /// <param name="settings">Settings of the ChakraCore JS engine</param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddEFFCChakraCore(this JsEngineFactoryCollection source, EFFCChakraCoreSettings settings)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            source.Add(new EFFCChakraCoreJsEngineFactory(settings));

            return(source);
        }
 /// <summary>
 /// Constructs an instance of the ChakraCore JS engine factory
 /// </summary>
 /// <param name="settings">Settings of the ChakraCore JS engine</param>
 public EFFCChakraCoreJsEngineFactory(EFFCChakraCoreSettings settings)
 {
     _settings = settings;
 }