How can I do the following in Mono.Cecil?
internal delegate object GenericGetter(object obj);
private GenericGetter CreateGetMethod(PropertyInfo propertyInfo)
{
MethodInfo getMethod = propertyInfo.GetGetMethod();
if (getMethod == null)
return null;
Type[] arguments = new Type[1];
arguments[0] = typeof(object);
DynamicMethod getter = new DynamicMethod("_", typeof(object),
arguments);
ILGenerator il = getter.GetILGenerator();
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Castclass, propertyInfo.DeclaringType);
il.EmitCall(OpCodes.Callvirt, getMethod, null);
if (!propertyInfo.PropertyType.IsClass)
il.Emit(OpCodes.Box, propertyInfo.PropertyType);
il.Emit(OpCodes.Ret);
return
(GenericGetter)getter.CreateDelegate(typeof(GenericGetter));
}
--
View this message in context:
http://mono.1490590.n4.nabble.com/How-can-I-tp3588598p3588598.html
Sent from the Mono - Cecil mailing list archive at Nabble.com.
--
--
mono-cecil