66using System . Linq ;
77using System . Threading ;
88using JavaScriptEngineSwitcher . Core ;
9+ using JavaScriptEngineSwitcher . Msie ;
910using JavaScriptEngineSwitcher . V8 ;
1011using JSPool ;
1112using React . Exceptions ;
@@ -72,7 +73,7 @@ IFileSystem fileSystem
7273 {
7374 _config = config ;
7475 _fileSystem = fileSystem ;
75- _factory = GetFactory ( availableFactories ) ;
76+ _factory = GetFactory ( availableFactories , config . AllowMsieEngine ) ;
7677 if ( _config . ReuseJavaScriptEngines )
7778 {
7879 _pool = CreatePool ( ) ;
@@ -197,7 +198,7 @@ public virtual void ReturnEngineToPool(IJsEngine engine)
197198 /// The first functioning JavaScript engine with the lowest priority will be used.
198199 /// </summary>
199200 /// <returns>Function to create JavaScript engine</returns>
200- private static Func < IJsEngine > GetFactory ( IEnumerable < Registration > availableFactories )
201+ private static Func < IJsEngine > GetFactory ( IEnumerable < Registration > availableFactories , bool allowMsie )
201202 {
202203 var availableEngineFactories = availableFactories
203204 . OrderBy ( x => x . Priority )
@@ -208,8 +209,7 @@ private static Func<IJsEngine> GetFactory(IEnumerable<Registration> availableFac
208209 try
209210 {
210211 engine = engineFactory ( ) ;
211- // Perform a sanity test to ensure this engine is usable
212- if ( engine . Evaluate < int > ( "1 + 1" ) == 2 )
212+ if ( EngineIsUsable ( engine , allowMsie ) )
213213 {
214214 // Success! Use this one.
215215 return engineFactory ;
@@ -246,6 +246,20 @@ private static Func<IJsEngine> GetFactory(IEnumerable<Registration> availableFac
246246 throw new ReactEngineNotFoundException ( ) ;
247247 }
248248
249+ /// <summary>
250+ /// Performs a sanity check to ensure the specified engine type is usable.
251+ /// </summary>
252+ /// <param name="engine">Engine to test</param>
253+ /// <param name="allowMsie">Whether the MSIE engine can be used</param>
254+ /// <returns></returns>
255+ private static bool EngineIsUsable ( IJsEngine engine , bool allowMsie )
256+ {
257+ // Perform a sanity test to ensure this engine is usable
258+ var isUsable = engine . Evaluate < int > ( "1 + 1" ) == 2 ;
259+ var isMsie = engine is MsieJsEngine ;
260+ return isUsable && ( ! isMsie || allowMsie ) ;
261+ }
262+
249263 /// <summary>
250264 /// Clean up all engines
251265 /// </summary>
0 commit comments