On 12 Jul 2013, at 21:48, [email protected] wrote:
> Can I obtain the generic template type from my ObjectSet MonoObject pointer
> rather than having to obtain it from a const char*.
> I am trying to write a "generic" routine for calling generic methods.
>
Perhaps another helper method is the way to go as working with generics
directly through the embedded API seems so unpalatable.
This seems to work.
public static Type[] GenericArgumentTypes(Type t)
{
Type[] types = null;
if (t.ContainsGenericParameters) {
types = t.GetGenericArguments ();
}
return types;
}
public static IntPtr GenericArgumentTypeAtIndex(Type t, int index)
{
Type argType = null;
Type[] genericTypes = t.GetGenericArguments();
if (genericTypes != null & index < genericTypes.Length) {
argType = genericTypes[index];
}
return argType.TypeHandle.Value;
}
I presume it will be slower invoking the C# rather than wrestling with the
runtime API directly but in my case the final method is cached in a Judy array
so it is a one time hit for each method signature called during the lifetime of
the domain.
Jonathan
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list