Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using reflection to create a manifest of all assets, strongly typed.

It's working fine for my own types: I get the type of the asset, if a processor is ran on it I get the output type. Then I check to see if there's a ContentSerializerRuntimeTypeAttribute applied to the type. If so, then I get the RuntimeType value and do a Type.GetType() to get the type back.

The problem I have is if the type is Texture2DContent (for example) as that doesn't have the ContentSerializerRuntimeTypeAttribute.

How can I go from a Type representing Texture2DContent to a Type representing Texture2D?

I know I can just check for EndsWith("Content") as a last resort, but how to I get the namespace qualified type so I can get my Type object?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Find all Types that inherit from ContentTypeWriter and have generic argument of Texture2DContent (actualy i think writer exists only for TextureContent), create instance of them and then call GetRuntimeType

share|improve this answer
    
Instead of getting only ContentTypeWriter<T> for my T i got all writers that had the ContentTypeWriterAttribute and were inherited from ContentTypeWriter. I then instanciated them all and picked the one that had the correct .TargetType. –  George Duckett Feb 13 '12 at 15:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.