/// <summary> /// Constructs a instance of adapter for the V8 JS engine (Microsoft ClearScript.V8) /// </summary> /// <param name="settings">Settings of the V8 JS engine</param> public V8JsEngine(V8Settings settings) { V8Settings v8Settings = settings ?? new V8Settings(); var constraints = new V8RuntimeConstraints { MaxNewSpaceSize = v8Settings.MaxNewSpaceSize, MaxOldSpaceSize = v8Settings.MaxOldSpaceSize, MaxExecutableSize = v8Settings.MaxExecutableSize }; V8ScriptEngineFlags flags = V8ScriptEngineFlags.None; if (v8Settings.EnableDebugging) { flags |= V8ScriptEngineFlags.EnableDebugging; } if (v8Settings.DisableGlobalMembers) { flags |= V8ScriptEngineFlags.DisableGlobalMembers; } int debugPort = v8Settings.DebugPort; try { _jsEngine = new V8ScriptEngine(constraints, flags, debugPort); } catch (Exception e) { throw new JsEngineLoadException( string.Format(CoreStrings.Runtime_JsEngineNotLoaded, EngineName, e.Message), EngineName, EngineVersion, e); } }
/// <summary> /// Constructs an instance of adapter for the V8 JS engine (Microsoft ClearScript.V8) /// </summary> /// <param name="settings">Settings of the V8 JS engine</param> public V8JsEngine(V8Settings settings) { V8Settings v8Settings = settings ?? new V8Settings(); var constraints = new OriginalRuntimeConstraints { HeapExpansionMultiplier = v8Settings.HeapExpansionMultiplier, MaxArrayBufferAllocation = v8Settings.MaxArrayBufferAllocation, MaxNewSpaceSize = v8Settings.MaxNewSpaceSize, MaxOldSpaceSize = v8Settings.MaxOldSpaceSize }; OriginalEngineFlags flags = OriginalEngineFlags.None; if (v8Settings.AwaitDebuggerAndPauseOnStart) { flags |= OriginalEngineFlags.AwaitDebuggerAndPauseOnStart; } if (v8Settings.EnableDebugging) { flags |= OriginalEngineFlags.EnableDebugging; } if (v8Settings.EnableRemoteDebugging) { flags |= OriginalEngineFlags.EnableRemoteDebugging; } if (v8Settings.DisableGlobalMembers) { flags |= OriginalEngineFlags.DisableGlobalMembers; } int debugPort = v8Settings.DebugPort; try { _jsEngine = new OriginalEngine(constraints, flags, debugPort) { MaxRuntimeHeapSize = v8Settings.MaxHeapSize, RuntimeHeapSizeSampleInterval = v8Settings.HeapSizeSampleInterval, MaxRuntimeStackUsage = v8Settings.MaxStackUsage }; } catch (TypeLoadException e) { throw WrapTypeLoadException(e); } catch (Exception e) { throw JsErrorHelpers.WrapEngineLoadException(e, EngineName, EngineVersion, true); } }
/// <summary> /// Adds a instance of <see cref="V8JsEngineFactory"/> to /// the specified <see cref="JsEngineFactoryCollection" /> /// </summary> /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param> /// <param name="settings">Settings of the V8 JS engine</param> /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns> public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection source, V8Settings settings) { if (source == null) { throw new ArgumentNullException("source"); } if (settings == null) { throw new ArgumentNullException("settings"); } source.Add(new V8JsEngineFactory(settings)); return(source); }
/// <summary> /// Adds a instance of <see cref="V8JsEngineFactory"/> to /// the specified <see cref="JsEngineFactoryCollection" /> /// </summary> /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param> /// <param name="settings">Settings of the V8 JS engine</param> /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns> public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection source, V8Settings settings) { if (source == null) { throw new ArgumentNullException("source"); } if (settings == null) { throw new ArgumentNullException("settings"); } source.Add(new V8JsEngineFactory(settings)); return source; }
/// <summary> /// Adds a instance of <see cref="V8JsEngineFactory"/> 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="V8Settings"/></param> /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns> public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection source, Action<V8Settings> configure) { if (source == null) { throw new ArgumentNullException("source"); } if (configure == null) { throw new ArgumentNullException("configure"); } var settings = new V8Settings(); configure(settings); return source.AddV8(settings); }
/// <summary> /// Adds a instance of <see cref="V8JsEngineFactory"/> 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="V8Settings"/></param> /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns> public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection source, Action <V8Settings> configure) { if (source == null) { throw new ArgumentNullException("source"); } if (configure == null) { throw new ArgumentNullException("configure"); } var settings = new V8Settings(); configure(settings); return(source.AddV8(settings)); }
/// <summary> /// Constructs an instance of the V8 JS engine factory /// </summary> /// <param name="settings">Settings of the V8 JS engine</param> public V8JsEngineFactory(V8Settings settings) { _settings = settings; }
/// <summary> /// Constructs an instance of the V8 JS engine factory /// </summary> /// <param name="settings">Settings of the V8 JS engine</param> public V8JsEngineFactory(V8Settings settings) { _settings = settings; }