CodeSmith Generator Maps allow developers to reduce the amount of plumbing code in their templates and increase the readability and reusability at the same time. CodeSmith Generator Maps also provide an easy way to manage dictionary maps for doing word translation lookups in code. This used to be a a frequent and cumbersome challenge that a template writer must face when trying to map types from disparate systems.
Generator includes a Map Editor that makes it very easy to create and manage your own CodeSmith Generator Map lists. Generator also ships several of the most common mapping scenarios and it's output is in a familiar XML format allowing the developer community to contribute and share maps they create as well through a new map file gallery at the CodeSmith community.
Opening the Map Editor
You can open the Map Editor from the Generator menu.
User interface elements
The section below will walk you through the various user interface elements of the Map Editor.
Name: The map name is also the file name so consider choosing a name that is fairly descriptive of what the map's intent is. This drop down allows you to edit and view previously defined map files.
If you select (New File) then a new mapping file will be created.
When Generator attempts to discover a map by name, it first looks in the configuration directories, the template directories and you can also give it a relative or full path.
New File: Clicking this button allows you to create a new mapping file.
Open File: Clicking this button will open a Windows Explorer Browse dialog and let you pick a mapping file that exists anywhere on your hard drive.
Save Copy: Creates a duplicate map file of the currently selected map file.
Description: A description field of what the maps intent is for.
Return Key: The return key check box indicates whether or not to return the original key from the map if the key is not found within the map. This is important because there can be many situations where there might not be an entry for the key and it's value, but you would still like the key returned instead of null.
In the image to the above, it's converting a fully qualified type to it's C# equivalent keyword. In cases where one doesn't exist, such as System.DateTime or System.Guid, you could still use the original key, System.DateTime, which would be completely valid.
Case Sensitive: The Case sensitive check box determines whether or not to search for the key and consider case sensitivity. Often, word dictionaries do not require case sensitivity since most use keys that are unique by name.
Find More: Launches a browser session to browse the online gallery of community collaborated maps.
to learn more about developing using a CodeSmith Generator Map.