@@ -207,47 +207,47 @@ public override void RunOnce()
207
207
}
208
208
209
209
#region Handwrittern //////////////////////////////////////////////////////////////////////
210
- public sealed class HandwrittenFooableEntwiner < T > : Entwiner , IFooable < T >
210
+ public sealed class HandwrittenFooableEntwiner < T > : IFooable < T >
211
211
{
212
+ private readonly AnyCall any_call ;
213
+
212
214
public HandwrittenFooableEntwiner ( AnyCall any_call )
213
- : base ( typeof ( IFooable < T > ) , any_call )
214
- { }
215
+ {
216
+ this . any_call = any_call ;
217
+ }
215
218
216
- void IFooable < T > . Aardvark ( ) => AnyCall ( 0 , Sys . Array . Empty < object > ( ) ) ;
217
- T IFooable < T > . Buffalo ( ) => ( T ) AnyCall ( 1 , Sys . Array . Empty < object > ( ) ) ;
218
- void IFooable < T > . Crocodile ( T t ) => AnyCall ( 2 , new object [ ] { t } ) ;
219
+ void IFooable < T > . Aardvark ( ) => any_call ( 0 , Sys . Array . Empty < object > ( ) ) ;
220
+ T IFooable < T > . Buffalo ( ) => ( T ) any_call ( 1 , Sys . Array . Empty < object > ( ) ) ;
221
+ void IFooable < T > . Crocodile ( T t ) => any_call ( 2 , new object [ ] { t } ) ;
219
222
220
223
void IFooable < T > . Dog ( T t , out T ot )
221
224
{
222
225
var args = new object [ ] { t , default ( T ) } ;
223
- AnyCall ( 3 , args ) ;
226
+ any_call ( 3 , args ) ;
224
227
ot = ( T ) args [ 1 ] ;
225
228
}
226
229
227
230
void IFooable < T > . Eagle ( T t , ref T rt )
228
231
{
229
232
var args = new object [ ] { t , rt } ;
230
- AnyCall ( 4 , args ) ;
233
+ any_call ( 4 , args ) ;
231
234
rt = ( T ) args [ 1 ] ;
232
235
}
233
236
234
- T IFooable < T > . Flamingo { get => ( T ) AnyCall ( 5 , Sys . Array . Empty < object > ( ) ) ; set => AnyCall ( 6 , new object [ ] { value } ) ; }
235
- T IFooable < T > . this [ T t ] { get => ( T ) AnyCall ( 7 , new object [ ] { t } ) ; set => AnyCall ( 8 , new object [ ] { t , value } ) ; }
237
+ T IFooable < T > . Flamingo { get => ( T ) any_call ( 5 , Sys . Array . Empty < object > ( ) ) ; set => any_call ( 6 , new object [ ] { value } ) ; }
238
+ T IFooable < T > . this [ T t ] { get => ( T ) any_call ( 7 , new object [ ] { t } ) ; set => any_call ( 8 , new object [ ] { t , value } ) ; }
236
239
}
237
240
238
- private sealed class HandwrittenFooableUntwiner < T > : Untwiner
241
+ private sealed class HandwrittenFooableUntwiner < T >
239
242
{
240
243
private readonly IFooable < T > target ;
241
244
242
245
public HandwrittenFooableUntwiner ( IFooable < T > target )
243
- : base ( typeof ( IFooable < T > ) )
244
246
{
245
247
this . target = target ;
246
248
}
247
249
248
- public override object Target => target ;
249
-
250
- public override object AnyCall ( int selector , object [ ] args )
250
+ public object AnyCall ( int selector , object [ ] args )
251
251
{
252
252
switch ( selector )
253
253
{
@@ -295,8 +295,8 @@ private sealed class BenchmarkHandwrittenInvocation : Benchmark
295
295
public BenchmarkHandwrittenInvocation ( )
296
296
{
297
297
IFooable < string > fooable = new FooImplementation < string > ( ) ;
298
- Untwiner untwiner = new HandwrittenFooableUntwiner < string > ( fooable ) ;
299
- entwiner = new HandwrittenFooableEntwiner < string > ( untwiner . AnyCall ) ;
298
+ AnyCall untwiner = new HandwrittenFooableUntwiner < string > ( fooable ) . AnyCall ;
299
+ entwiner = new HandwrittenFooableEntwiner < string > ( untwiner ) ;
300
300
}
301
301
302
302
public override void RunOnce ( )
@@ -307,20 +307,20 @@ public override void RunOnce()
307
307
#endregion
308
308
309
309
#region Castle Benchmarking Routines //////////////////////////////////////////////////////
310
- private sealed class BenchmarkCastleCreation /*WithCaching*/ : Benchmark
310
+ private sealed class BenchmarkCastleCreation /*WithCaching*/ : Benchmark
311
311
{
312
312
private readonly IFooable < string > fooable ;
313
313
314
- public BenchmarkCastleCreation /*WithCaching*/ ( )
314
+ public BenchmarkCastleCreation /*WithCaching*/ ( )
315
315
{
316
316
fooable = new FooImplementation < string > ( ) ;
317
317
//CastleProxyGenerator.ProxyBuilder.ModuleScope.IsCaching = true; This used to compile, but not anymore. It appears that they discontinued the "IsCaching" property.
318
318
}
319
319
320
320
public override void RunOnce ( )
321
321
{
322
- Untwiner untwiner = CastleGetUntwiner ( fooable ) ;
323
- CastleGetEntwiner < IFooable < string > > ( untwiner . AnyCall ) ;
322
+ AnyCall untwiner = CastleGetUntwiner ( fooable ) ;
323
+ CastleGetEntwiner < IFooable < string > > ( untwiner ) ;
324
324
}
325
325
}
326
326
@@ -331,8 +331,8 @@ private sealed class BenchmarkCastleInvocation : Benchmark
331
331
public BenchmarkCastleInvocation ( )
332
332
{
333
333
IFooable < string > fooable = new FooImplementation < string > ( ) ;
334
- Untwiner untwiner = CastleGetUntwiner ( fooable ) ;
335
- entwiner = CastleGetEntwiner < IFooable < string > > ( untwiner . AnyCall ) ;
334
+ AnyCall untwiner = CastleGetUntwiner ( fooable ) ;
335
+ entwiner = CastleGetEntwiner < IFooable < string > > ( untwiner ) ;
336
336
}
337
337
338
338
public override void RunOnce ( )
@@ -349,28 +349,29 @@ public static T CastleGetEntwiner<T>( AnyCall any_call ) where T : class //actua
349
349
return CastleProxyGenerator . CreateInterfaceProxyWithoutTarget < T > ( interceptor ) ;
350
350
}
351
351
352
- public static Untwiner CastleGetUntwiner < T > ( T target ) where T : class //actually, interface
352
+ public static AnyCall CastleGetUntwiner < T > ( T target ) where T : class //actually, interface
353
353
{
354
354
// The Castle DynamicProxy does not offer any untwining functionality, so we use a reflecting untwiner.
355
- return new ReflectingUntwiner ( typeof ( T ) , target ) ;
355
+ return new ReflectingUntwiner ( typeof ( T ) , target ) . AnyCall ;
356
356
}
357
357
358
- private sealed class EntwinerForCastle : Entwiner , CastleDP . IInterceptor
358
+ private sealed class EntwinerForCastle : CastleDP . IInterceptor
359
359
{
360
+ private readonly AnyCall any_call ;
360
361
private readonly Dictionary < SysReflect . MethodInfo , int > selector_map = new Dictionary < SysReflect . MethodInfo , int > ( ) ;
361
362
362
363
public EntwinerForCastle ( System . Type interface_type , AnyCall any_call )
363
- : base ( interface_type , any_call )
364
364
{
365
- var method_infos = InterfaceType . GetMethods ( SysReflect . BindingFlags . Public | SysReflect . BindingFlags . NonPublic | SysReflect . BindingFlags . Instance ) ;
365
+ this . any_call = any_call ;
366
+ var method_infos = interface_type . GetMethods ( SysReflect . BindingFlags . Public | SysReflect . BindingFlags . NonPublic | SysReflect . BindingFlags . Instance ) ;
366
367
for ( int i = 0 ; i < method_infos . Length ; i ++ )
367
368
selector_map . Add ( method_infos [ i ] , i ) ;
368
369
}
369
370
370
371
void CastleDP . IInterceptor . Intercept ( CastleDP . IInvocation invocation )
371
372
{
372
373
int selector = selector_map [ invocation . Method ] ;
373
- invocation . ReturnValue = AnyCall ( selector , invocation . Arguments ) ;
374
+ invocation . ReturnValue = any_call ( selector , invocation . Arguments ) ;
374
375
}
375
376
}
376
377
#endregion
@@ -475,22 +476,23 @@ public static AnyCall LinFuGetUntwiner<T>( T target )
475
476
return new ReflectingUntwiner ( typeof ( T ) , target ) . AnyCall ;
476
477
}
477
478
478
- private sealed class EntwinerForLinFu : Entwiner , LinFuDP . IInterceptor
479
+ private sealed class EntwinerForLinFu : LinFuDP . IInterceptor
479
480
{
481
+ private readonly AnyCall any_call ;
480
482
private readonly Dictionary < SysReflect . MethodInfo , int > selector_map = new Dictionary < SysReflect . MethodInfo , int > ( ) ;
481
483
482
- public EntwinerForLinFu ( System . Type interface_type , AnyCall any_call )
483
- : base ( interface_type , any_call )
484
+ public EntwinerForLinFu ( Sys . Type interface_type , AnyCall any_call )
484
485
{
485
- var method_infos = InterfaceType . GetMethods ( SysReflect . BindingFlags . Public | SysReflect . BindingFlags . NonPublic | SysReflect . BindingFlags . Instance ) ;
486
+ this . any_call = any_call ;
487
+ var method_infos = interface_type . GetMethods ( SysReflect . BindingFlags . Public | SysReflect . BindingFlags . NonPublic | SysReflect . BindingFlags . Instance ) ;
486
488
for ( int i = 0 ; i < method_infos . Length ; i ++ )
487
489
selector_map . Add ( method_infos [ i ] , i ) ;
488
490
}
489
491
490
492
object LinFuDP . IInterceptor . Intercept ( LinFuDP . InvocationInfo info )
491
493
{
492
494
int selector = selector_map [ info . TargetMethod ] ;
493
- return AnyCall ( selector , info . Arguments ) ;
495
+ return any_call ( selector , info . Arguments ) ;
494
496
}
495
497
}
496
498
#endregion
0 commit comments