malignate88

I implemented a scenegraph and have several ContentProcessors, ContentReadersWriters and ContentTypeReaders. Because all the objects have the same base class, i want to have all ContentTypeReaders to use the same type, but i get an error. Is this not possible


Re: XNA Framework 2 ContentTypeReaders with the same return type.

Jon Watte

The ContentTypeReader needs to read the specific subclass. If that's not possible for you, then you need to write a single ContentTypeReader that returns the appropriate subclass through the base class interface.

This is fairly obvious, if you think about it: Which reader would Load<SomeType> call if it had to choose between multiple






Re: XNA Framework 2 ContentTypeReaders with the same return type.

CodePfo

You might be able to create a hierarchy of ContentTypeReaders that inherit from each other, but you'd end up having a 1-1 correspondence between each class, each reader and each writer. This is an interesting idea that might end up saving you time with some thought.

"
This is fairly obvious, if you think about it: Which reader would Load<SomeType> call if it had to choose between multiple "

I believe that is determined by the ContentTypeWriter class. So you could have 2 classes, written with different ContentTypeWriters, each that uses a different ContentTypeReader (I think...)