using System; using JavaScriptEngineSwitcher.Core; namespace JavaScriptEngineSwitcher.V8 { /// /// JS engine factory collection extensions /// public static class JsEngineFactoryCollectionExtensions { /// /// Adds a instance of to /// the specified /// /// Instance of /// Instance of public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection source) { if (source is null) { throw new ArgumentNullException(nameof(source)); } return source.AddV8(new V8Settings()); } /// /// Adds a instance of to /// the specified /// /// Instance of /// The delegate to configure the provided /// Instance of public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection source, Action configure) { if (source is null) { throw new ArgumentNullException(nameof(source)); } if (configure is null) { throw new ArgumentNullException(nameof(configure)); } var settings = new V8Settings(); configure(settings); return source.AddV8(settings); } /// /// Adds a instance of to /// the specified /// /// Instance of /// Settings of the V8 JS engine /// Instance of public static JsEngineFactoryCollection AddV8(this JsEngineFactoryCollection source, V8Settings settings) { if (source is null) { throw new ArgumentNullException(nameof(source)); } if (settings is null) { throw new ArgumentNullException(nameof(settings)); } source.Add(new V8JsEngineFactory(settings)); return source; } } }