/// <summary>
        /// Adds a instance of <see cref="NodeJsEngineFactory"/> to
        /// the specified <see cref="JsEngineFactoryCollection" />
        /// </summary>
        /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param>
        /// <param name="services">The services available in the application</param>
        /// <param name="configure">The delegate to configure the provided <see cref="NodeSettings"/></param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source,
                                                        IServiceCollection services, Action <NodeSettings> configure)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

            var settings = new NodeSettings();

            configure(settings);

            source.Add(new NodeJsEngineFactory(services, settings));

            return(source);
        }
        /// <summary>
        /// Adds a instance of <see cref="MsieJsEngineFactory"/> to
        /// the specified <see cref="JsEngineFactoryCollection" />
        /// </summary>
        /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddMsie(this JsEngineFactoryCollection source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(source.AddMsie(new MsieSettings()));
        }
        /// <summary>
        /// Adds a instance of <see cref="NiLJsEngineFactory"/> to
        /// the specified <see cref="JsEngineFactoryCollection" />
        /// </summary>
        /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddNiL(this JsEngineFactoryCollection source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            return(source.AddNiL(new NiLSettings()));
        }
        /// <summary>
        /// Adds a instance of <see cref="NodeJsEngineFactory"/> to
        /// the specified <see cref="JsEngineFactoryCollection" />
        /// </summary>
        /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            source.Add(new NodeJsEngineFactory());

            return(source);
        }
        /// <summary>
        /// Adds a instance of <see cref="NiLJsEngineFactory"/> to
        /// the specified <see cref="JsEngineFactoryCollection" />
        /// </summary>
        /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param>
        /// <param name="settings">Settings of the NiL JS engine</param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddNiL(this JsEngineFactoryCollection source, NiLSettings settings)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

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

            source.Add(new NiLJsEngineFactory(settings));

            return(source);
        }
Пример #6
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>
        /// Adds a instance of <see cref="JintJsEngineFactory"/> to
        /// the specified <see cref="JsEngineFactoryCollection" />
        /// </summary>
        /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param>
        /// <param name="settings">Settings of the Jint JS engine</param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddJint(this JsEngineFactoryCollection source, JintSettings settings)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

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

            source.Add(new JintJsEngineFactory(settings));

            return(source);
        }
        /// <summary>
        /// Adds a instance of <see cref="MsieJsEngineFactory"/> 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="MsieSettings"/></param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddMsie(this JsEngineFactoryCollection source,
                                                        Action <MsieSettings> configure)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

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

            var settings = new MsieSettings();

            configure(settings);

            return(source.AddMsie(settings));
        }
        /// <summary>
        /// Adds a instance of <see cref="NiLJsEngineFactory"/> 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="NiLSettings"/></param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddNiL(this JsEngineFactoryCollection source,
                                                       Action <NiLSettings> configure)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

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

            var settings = new NiLSettings();

            configure(settings);

            return(source.AddNiL(settings));
        }
        /// <summary>
        /// Adds a instance of <see cref="NodeJsEngineFactory"/> to
        /// the specified <see cref="JsEngineFactoryCollection" />
        /// </summary>
        /// <param name="source">Instance of <see cref="JsEngineFactoryCollection" /></param>
        /// <param name="services">The services available in the application</param>
        /// <param name="settings">Settings of the Node JS engine</param>
        /// <returns>Instance of <see cref="JsEngineFactoryCollection" /></returns>
        public static JsEngineFactoryCollection AddNode(this JsEngineFactoryCollection source,
                                                        IServiceCollection services, NodeSettings settings)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

            source.Add(new NodeJsEngineFactory(services, settings));

            return(source);
        }
		/// <summary>
		/// Private constructor for implementation Singleton pattern
		/// </summary>
		private JsEngineSwitcher()
		{
			DefaultEngineName = string.Empty;
			EngineFactories = new JsEngineFactoryCollection();
		}