I don't think it's possible. My understanding is that GetTypeHandle()
returns a handle (pointer) to a class object. Within a class object is a
reference to the type it is, and this is something that is maintained by the
runtime; not accessible in any other way.
This is an interesting topic, and I'm interested in possibly being proven
that I'm wrong since this is currently something I'm beginning to explore in
ROTOR - how the type maintains its identity, etc.
Unless I've completely misunderstood your situation, I don't think you can
spoof GetTypeHandle() to return anything but a pointer to the class object.
> hello!
> is there any way how to return custom type for specific class using typeof
[quoted text clipped - 97 lines]
>
> thank you for any suggestions, critics or comments.
bandzuch martin - 13 Nov 2003 08:48 GMT
my plan is to create statical C# classes model from UML model.
and i want to realize association elements as references to classType.
so i need to create for each class corresponding classRuntimeType and
associate
it with that class. i had also looked at sscli and found some code, but had
not found
the whole principle and association with the System.Type and
System.RuntimeType classes yet.
i am confused about System.Type class because it is abstract, public and
there is written some
'note to implementors', so there should be some reason to derive from
System.Type for custom
type implementors. May be there is some other reason that i see ( create
custom classType ) but
i can't figure out.
and if it is possible to create custom classType, it's use is limited
without possibility to attach it to corresponding
class.
now i am trying to realize that mapping ( uml model -> c# classes ) some
other way, maybe attributes will
provide sufficient potential to realize it.
thak you for your interest and time.
> I don't think it's possible. My understanding is that GetTypeHandle()
> returns a handle (pointer) to a class object. Within a class object is a
[quoted text clipped - 7 lines]
> Unless I've completely misunderstood your situation, I don't think you can
> spoof GetTypeHandle() to return anything but a pointer to the class object.