Preamble:
I'm working with an XNA Content project to hold all of the various textures (and possibly other resources) that I'm using as part of developing a game.
The default method of loading images from the Content project into an XNA texture object involves the use of hard coded string literals to point to the various files.
I would like to automate the projection of the directory/file tree inside the content project into an object hierarchy to avoid using string literals directly, and to gain the benefits of using strongly typed objects.
Example:
Instead of using
Texture2D tex = Content.Load("Textures/defaultTexture32");
I'd much prefer
Texture2D tex = Content.Load(Content.Textures.defaultTexture32);
Question:
Is there an already existing solution to this problem? (I couldn't find anything with Google)
Extra details:
I'm fairly certain this can be done through a T4 template; probably in conjunction with the DTE tools. I've made an initial attempt to do this, but I keep hitting blocks due to my inexperience with both tool sets, but I've worked with T4MVC in the past which does something similar; unfortunately it projects class structure rather than the file system and is not easily adapted.
I do not require the solution to use T4 or DTE, they simply seem as though they're likely to be part of a solution.
Only including files that are part of the VS project (rather than the entire on-disk file system) would be preferable, but not necessary.
The ability to additionally filter by file types, etc. would be an extra special bonus.
For anyone that doesn't immediately see the benefits of doing this; consider what would happen if you renamed or deleted the file. The application would continue to compile fine, but it would crash at runtime. Perhaps not until a very special set of circumstances are met for a certain file to be accessed. If all the file names are projected into an object structure (which is regenerated every time you build the project, or perhaps even every time you modify) then you will get compile-time errors pointing out the missing resources and possibly avoid a lot of future pain.
Thanks for your time.