1
1
using System ;
2
2
using System . Reflection ;
3
- #if NET45
4
- using System . Runtime . ExceptionServices ;
5
- #endif
6
3
using System . Text . RegularExpressions ;
7
4
8
5
using Microsoft . ClearScript . V8 ;
@@ -44,11 +41,6 @@ public sealed class V8JsEngine : JsEngineBase
44
41
/// </summary>
45
42
private static OriginalUndefined _originalUndefinedValue ;
46
43
47
- /// <summary>
48
- /// Information about <code>InvokeMethod</code> method of <see cref="V8ScriptItem"/> class
49
- /// </summary>
50
- private static MethodInfo _v8ScriptItemInvokeMethodInfo ;
51
-
52
44
/// <summary>
53
45
/// Regular expression for working with the string representation of error
54
46
/// </summary>
@@ -69,7 +61,6 @@ static V8JsEngine()
69
61
{
70
62
AssemblyResolver . Initialize ( ) ;
71
63
LoadUndefinedValue ( ) ;
72
- LoadWinScriptItemInvokeMethodInfo ( ) ;
73
64
}
74
65
75
66
/// <summary>
@@ -144,36 +135,6 @@ private static void LoadUndefinedValue()
144
135
}
145
136
}
146
137
147
- /// <summary>
148
- /// Loads a `InvokeMethod` method information of `Microsoft.ClearScript.V8.V8ScriptItem` type
149
- /// </summary>
150
- private static void LoadWinScriptItemInvokeMethodInfo ( )
151
- {
152
- const string typeName = "Microsoft.ClearScript.V8.V8ScriptItem" ;
153
- const string methodName = "InvokeMethod" ;
154
-
155
- Assembly clearScriptAssembly = typeof ( V8ScriptEngine ) . Assembly ;
156
- Type v8ScriptItemType = clearScriptAssembly . GetType ( typeName ) ;
157
- MethodInfo v8ScriptItemInvokeMethodInfo = null ;
158
-
159
- if ( v8ScriptItemType != null )
160
- {
161
- v8ScriptItemInvokeMethodInfo = v8ScriptItemType . GetMethod ( methodName ,
162
- BindingFlags . Instance | BindingFlags . Public ) ;
163
- }
164
-
165
- if ( v8ScriptItemInvokeMethodInfo != null )
166
- {
167
- _v8ScriptItemInvokeMethodInfo = v8ScriptItemInvokeMethodInfo ;
168
- }
169
- else
170
- {
171
- throw new JsEngineLoadException (
172
- string . Format ( Strings . Runtime_MethodInfoNotLoaded , typeName , methodName ) ,
173
- EngineName , EngineVersion ) ;
174
- }
175
- }
176
-
177
138
#region Mapping
178
139
179
140
/// <summary>
@@ -329,43 +290,15 @@ protected override object InnerCallFunction(string functionName, params object[]
329
290
{
330
291
try
331
292
{
332
- object obj = _jsEngine . Script ;
333
- result = _v8ScriptItemInvokeMethodInfo . Invoke ( obj , new object [ ] { functionName , processedArgs } ) ;
293
+ result = _jsEngine . Invoke ( functionName , processedArgs ) ;
334
294
}
335
- catch ( TargetInvocationException e )
295
+ catch ( OriginalScriptEngineException e )
296
+ {
297
+ throw ConvertScriptEngineExceptionToHostException ( e ) ;
298
+ }
299
+ catch ( OriginalScriptInterruptedException e )
336
300
{
337
- Exception innerException = e . InnerException ;
338
- if ( innerException != null )
339
- {
340
- if ( innerException is IOriginalScriptEngineException )
341
- {
342
- var scriptEngineException = innerException as OriginalScriptEngineException ;
343
- if ( scriptEngineException != null )
344
- {
345
- throw ConvertScriptEngineExceptionToHostException ( scriptEngineException ) ;
346
- }
347
-
348
- var scriptInterruptedException =
349
- innerException as OriginalScriptInterruptedException ;
350
- if ( scriptInterruptedException != null )
351
- {
352
- throw ConvertScriptInterruptedExceptionToHostException (
353
- scriptInterruptedException ) ;
354
- }
355
- }
356
- #if NET45
357
-
358
- ExceptionDispatchInfo . Capture ( innerException ) . Throw ( ) ;
359
- #elif NET40
360
-
361
- innerException . PreserveStackTrace ( ) ;
362
- throw innerException ;
363
- #else
364
- #error No implementation for this target
365
- #endif
366
- }
367
-
368
- throw ;
301
+ throw ConvertScriptInterruptedExceptionToHostException ( e ) ;
369
302
}
370
303
}
371
304
0 commit comments