public JsEngineManager(IJsEngineManagerConfiguration config) { this._config = config; if (config == null) { throw new ArgumentNullException(nameof(config)); } this._modules = config.Modules ?? new List <string>(); // replace with custom object & mapping this._poolConfig = new JsPoolConfig { EngineFactory = new ChakraCoreJsEngineFactory().CreateEngine, Initializer = this.Initializer() }; if (config.StartEngines.HasValue) { this._poolConfig.StartEngines = config.StartEngines.Value; } if (config.MaxEngines.HasValue) { this._poolConfig.MaxEngines = config.MaxEngines.Value; } if (config.MaxUsagesPerEngine.HasValue) { this._poolConfig.MaxUsagesPerEngine = config.MaxUsagesPerEngine.Value; } this._pool = new JsPool(this._poolConfig); }
public static void Initialize(IJsEngineManagerConfiguration config) { if (_current != null) { throw new Exception("JsEngine is already initialized"); } lock (SyncObject) { if (_current == null) { _current = new Locator(config); } } }
public JsEngineManager(IJsEngineManagerConfiguration config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } this._modules = ResolvePaths(config.Modules ?? new List <string>()).ToList(); // replace with custom object & mapping this._poolConfig = new JsPoolConfig { EngineFactory = new ChakraCoreJsEngineFactory().CreateEngine, Initializer = this.Initializer() }; if (this._modules.Count > 0) { // Get common root path for all files and configure watching. this._poolConfig.WatchPath = this.GetCommonRoot(this._modules); this._poolConfig.WatchFiles = this._modules; } if (config.StartEngines.HasValue) { this._poolConfig.StartEngines = config.StartEngines.Value; } if (config.MaxEngines.HasValue) { this._poolConfig.MaxEngines = config.MaxEngines.Value; } if (config.MaxUsagesPerEngine.HasValue) { this._poolConfig.MaxUsagesPerEngine = config.MaxUsagesPerEngine.Value; } this._pool = new JsPool(this._poolConfig); // Clean combined scripts on any script file change this._pool.Recycled += (sender, args) => { this._scripts = null; }; }
protected Locator(IJsEngineManagerConfiguration config) { this.Page = new PageContext(); this.Manager = new JsEngineManager(config); }