C# Class React.JavaScriptEngineFactory

Handles creation of JavaScript engines. All methods are thread-safe.
Inheritance: IDisposable, IJavaScriptEngineFactory
Afficher le fichier Open project: reactjs/React.NET

Protected Properties

Свойство Type Description
_config IReactSiteConfiguration
_disposed bool
_engines IJsEngine>.ConcurrentDictionary
_factory Func
_fileSystem IFileSystem
_jsEngineSwitcher JavaScriptEngineSwitcher.Core.JsEngineSwitcher
_pool IJsPool
_scriptLoadException System.Exception

Méthodes publiques

Méthode Description
Dispose ( ) : void

Clean up all engines

DisposeEngineForCurrentThread ( ) : void

Disposes the JavaScript engine for the current thread.

EnsureValidState ( ) : void

Ensures that this object has not been disposed, and that no error was thrown while loading the scripts.

GetEngine ( ) : IJsEngine

Gets a JavaScript engine from the pool.

GetEngineForCurrentThread ( ) : IJsEngine

Gets the JavaScript engine for the current thread. It is recommended to use GetEngine instead, which will pool/reuse engines.

JavaScriptEngineFactory ( JsEngineSwitcher jsEngineSwitcher, IReactSiteConfiguration config, IFileSystem fileSystem ) : System

Initializes a new instance of the JavaScriptEngineFactory class.

ReturnEngineToPool ( IJsEngine engine ) : void

Returns an engine to the pool so it can be reused

Méthodes protégées

Méthode Description
CreatePool ( ) : IJsPool

Creates a new JavaScript engine pool.

InitialiseEngine ( IJsEngine engine ) : void

Loads standard React and Babel scripts into the engine.

Private Methods

Méthode Description
EngineIsUsable ( IJsEngine engine, bool allowMsie ) : bool

Performs a sanity check to ensure the specified engine type is usable.

EnsureJsEnginesRegistered ( JsEngineSwitcher jsEngineSwitcher, bool allowMsie ) : void

Ensures that some engines have been registered with JavaScriptEngineSwitcher. IF not, registers some default engines.

EnsureReactLoaded ( IJsEngine engine ) : void

Ensures that React has been correctly loaded into the specified engine.

GetFactory ( JsEngineSwitcher jsEngineSwitcher, bool allowMsie ) : Func

Gets a factory for the most appropriate JavaScript engine for the current environment. The first functioning JavaScript engine with the lowest priority will be used.

LoadUserScripts ( IJsEngine engine ) : void

Loads any user-provided scripts. Only scripts that don't need JSX transformation can run immediately here. JSX files are loaded in ReactEnvironment.

Method Details

CreatePool() protected méthode

Creates a new JavaScript engine pool.
protected CreatePool ( ) : IJsPool
Résultat IJsPool

Dispose() public méthode

Clean up all engines
public Dispose ( ) : void
Résultat void

DisposeEngineForCurrentThread() public méthode

Disposes the JavaScript engine for the current thread.
public DisposeEngineForCurrentThread ( ) : void
Résultat void

EnsureValidState() public méthode

Ensures that this object has not been disposed, and that no error was thrown while loading the scripts.
public EnsureValidState ( ) : void
Résultat void

GetEngine() public méthode

Gets a JavaScript engine from the pool.
public GetEngine ( ) : IJsEngine
Résultat IJsEngine

GetEngineForCurrentThread() public méthode

Gets the JavaScript engine for the current thread. It is recommended to use GetEngine instead, which will pool/reuse engines.
public GetEngineForCurrentThread ( ) : IJsEngine
Résultat IJsEngine

InitialiseEngine() protected méthode

Loads standard React and Babel scripts into the engine.
protected InitialiseEngine ( IJsEngine engine ) : void
engine IJsEngine
Résultat void

JavaScriptEngineFactory() public méthode

Initializes a new instance of the JavaScriptEngineFactory class.
public JavaScriptEngineFactory ( JsEngineSwitcher jsEngineSwitcher, IReactSiteConfiguration config, IFileSystem fileSystem ) : System
jsEngineSwitcher JavaScriptEngineSwitcher.Core.JsEngineSwitcher
config IReactSiteConfiguration
fileSystem IFileSystem
Résultat System

ReturnEngineToPool() public méthode

Returns an engine to the pool so it can be reused
public ReturnEngineToPool ( IJsEngine engine ) : void
engine IJsEngine Engine to return
Résultat void

Property Details

_config protected_oe property

React configuration for the current site
protected IReactSiteConfiguration _config
Résultat IReactSiteConfiguration

_disposed protected_oe property

Whether this class has been disposed.
protected bool _disposed
Résultat bool

_engines protected_oe property

Contains all current JavaScript engine instances. One per thread, keyed on thread ID.
protected ConcurrentDictionary _engines
Résultat IJsEngine>.ConcurrentDictionary

_factory protected_oe property

Function used to create new JavaScript engine instances.
protected Func _factory
Résultat Func

_fileSystem protected_oe property

File system wrapper
protected IFileSystem _fileSystem
Résultat IFileSystem

_jsEngineSwitcher protected_oe property

The JavaScript Engine Switcher instance used by ReactJS.NET
protected JsEngineSwitcher,JavaScriptEngineSwitcher.Core _jsEngineSwitcher
Résultat JavaScriptEngineSwitcher.Core.JsEngineSwitcher

_pool protected_oe property

Pool of JavaScript engines to use
protected IJsPool _pool
Résultat IJsPool

_scriptLoadException protected_oe property

The exception that was thrown during the most recent recycle of the pool.
protected Exception,System _scriptLoadException
Résultat System.Exception