Resource File Wrapper (Generator)

by Jason Haley 14. November 2004 09:04

In order to write code that uses resources that reside in resource files, I wrote a wrapper class (you know a class that would have a strongly typed property for each resource in the resource file) ... and then I wrote a little application to generate that wrapper. You can now Read the details or download the code The classes are generated using XSLT templates that are included with the dll project in the download - so you can tweak them as you see fit.

It will generate a wrapper in VB.Net, C# or managed C++.... yea thats right managed C++.  Using the wrapper class it will allow you to write code like this


  120
         Images imageResource = new Images();

  121         _pbImage.Image = imageResource.DiscoveryPark5;

 

Instead of code like this:


  120
         Assembly assembly = Assembly.GetExecutingAssembly();

  121         ResourceManager resources = new ResourceManager("HenleyCSharp.Images", assembly);

  122         _pbImage.Image = (Image)resources.GetObject(DISCOVERYPARK5);

 

BTW: any of you C++ (or VB and C#) folks that download the code an find anything wrong with the generated code, please let me know.  The templates were designed to create a wrapper that works with the sample applications in my resource files article (not done yet) ... of which I have C#, C++ and VB.Net versions.

Comments (4) | Post RSSRSS comment feed |

Categories:
Tags:

Comments

Comments are closed