[Mono-list] MonoObject of type System.Type to MonoClass (C)

Maciej Piechotka uzytkownik2 at gmail.com
Fri Dec 15 05:16:00 EST 2006


On Fri, 15 Dec 2006 10:36:14 +0100, Robert Jordan wrote:

> Maciej Piechotka wrote:
>> I have a collection which I got from dll. However I have a objects of
>> System.Type and I want to have MonoClass.
> 
> 
> System.Type is represented by MonoReflectionType* in the embedded
> API. Unfortunately there is no documented/public way to obtain
> the MonoType* from a MonoReflectionType*, at least I didn't
> find one.
> 
> The workaround is to declare this in your code:
> 
> 
> /*
>   * FIXME: propose mono_reflection_type_get_XYZ () accessors.
>   */
> struct _MonoReflectionType {
> 	MonoObject object;
> 	MonoType  *type;
> };
> 
> 
> Supposing your System.Type is in the var `obj', you can
> obtain the MonoClass* this way:
> 
> mono_class_from_mono_type ((MonoReflectionType*)obj)->type);
> 
> Robert
> 

I suppose there are no guarantee that it will work in future versions of
Mono?

I'll try it anyway.

Regards

-- 
I've probably left my head... somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)



More information about the Mono-list mailing list