I am looking for some advice on a good design for loading lookup tables such as state codes using Prism Unity? My view libraries are domain focused and I have modules that pass in an IUnityContainer. In the initialize section I register with the container the RegisterType such as IStateCode, StateCode.
Should I registerType, then load the state object and then use RegisterInstance? Should this be done in each domain (dll) or should I centrally load the tables once, and where? I thought about loading the lookup tables in the Load of the mainwindow, but I would have to reference all of the lookup classes in that module. If I use a central location to load the lookup tables, I don't have to worry about lookup tables being null and it's located in one area. How say yee?
The approach that I have taken with this sort of thing is to create a central project in the solution; that could be called Core.UI (or whatever you like). There, I create a class that I register with the container as a singleton, which loads the data it needs at application start up (via the Initialize call; see code). This is commonly referred to as a service.
You could make when the data is loaded as flexible as you like. At application load time, or the first time the property is accessed. I do mine up front, since the data is not huge, and it doesn't change that often. You may even want to consider some sort of caching mechanism here, too.
I have done something similar for products, too. Below is for US state codes.
EDIT:
To register the above as a singleton in Prism 6, add this line of code to the method you use to initialize your container. Usually in the bootstapper.
RegisterTypeIfMissing(typeof(IStateListService), typeof(StateListService), true);