Skip to content

Commit

Permalink
Repare reflection example
Browse files Browse the repository at this point in the history
  • Loading branch information
Puresharper committed Mar 30, 2017
1 parent 9f08b6e commit b1905b8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions NConcern/NConcern.Example.Reflection/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public IEnumerable<IAdvice> Advise(MethodBase method)
{
var _exception = _ILGenerator.DeclareLocal(Metadata<Exception>.Type);
var _trace = _ILGenerator.DeclareLocal(Metadata<Trace>.Type);
_ILGenerator.Emit(OpCodes.Ldtoken, method);
if (method is ConstructorInfo) { _ILGenerator.Emit(OpCodes.Ldtoken, method as ConstructorInfo); }
else { _ILGenerator.Emit(OpCodes.Ldtoken, method as MethodInfo); }
_ILGenerator.Emit(OpCodes.Ldtoken, method.ReflectedType);
_ILGenerator.Emit(OpCodes.Call, Metadata.Method(() => MethodBase.GetMethodFromHandle(Argument<RuntimeMethodHandle>.Value, Argument<RuntimeTypeHandle>.Value)));
_ILGenerator.Emit(OpCodes.Ldc_I4, _parameters.Length);
Expand Down Expand Up @@ -59,7 +60,8 @@ public IEnumerable<IAdvice> Advise(MethodBase method)
var _exception = _ILGenerator.DeclareLocal(Metadata<Exception>.Type);
var _trace = _ILGenerator.DeclareLocal(Metadata<Trace>.Type);
var _return = _ILGenerator.DeclareLocal(_type);
_ILGenerator.Emit(OpCodes.Ldtoken, method);
if (method is ConstructorInfo) { _ILGenerator.Emit(OpCodes.Ldtoken, method as ConstructorInfo); }
else { _ILGenerator.Emit(OpCodes.Ldtoken, method as MethodInfo); }
_ILGenerator.Emit(OpCodes.Ldtoken, method.ReflectedType);
_ILGenerator.Emit(OpCodes.Call, Metadata.Method(() => MethodBase.GetMethodFromHandle(Argument<RuntimeMethodHandle>.Value, Argument<RuntimeTypeHandle>.Value)));
_ILGenerator.Emit(OpCodes.Ldc_I4, _parameters.Length);
Expand Down

0 comments on commit b1905b8

Please sign in to comment.