|
If you develop a new generator or have an existing generator that is not part of your Xomega model project, you can easily add it to your project file, which will allow you to configure and run the generator from Visual Studio or run it from a command line either manually or automatically as part of the build process. Running it from a command line could be useful on a build server during continuous integration. The following steps explain the details on how to add the generator to your model project file. - Add an XomGenerator element under the ItemGroup element that contains other generators. If you need the generators to be run in a certain sequence, then you can arrange the XomGenerator nodes accordingly.
- Set the Include attribute to the full path of the generator's XSL. You can use the $(XomegaHome) parameter to specify the Xomega installation folder including the trailing slash.
- Add a child Name element and set the generator's name as its value.
- Add a child Folder element and set its value to be the slash delimited folder path that will be used to group and organize generators in the model project.
- Add a child OutputPath element and set its value to the output path for the generator using appropriate placeholders as supported by the generator.
- Add a child IncludeInBuild element and set its value to true, if you want the generator to be automatically run when you build the model project, and to false, if you need to run it manually.
- Add a child IndividualFiles element and set its value to true, if your generator can be run for selected file(s) only through a contextual menu, and to false, if it can only be run for all files in the model.
- If your generator is using a database connection then add a child DbConnection element, which should contain a connection string as its value. You can also set it to use the project default connection by using the $(DbConnection) variable as the value.
- Similarly, if your generator needs to use any other database related parameters that are specified when setting up a database connection, such as Database, DbCase, DbTimeout or DbExcludeTables, then add them accordingly. Use the corresponding parameters as a value to specify the project default.
- For any additional parameter that your generator uses, define the parameter elements as child nodes of the generator. Some of the most common parameters, which are defined in the Xomega common XSL scripts, are AddToProject and LinkIntoProject, which store the relative path to another project, and allow you to automatically add the generated files into those projects either directly or as links respectively.
The following snippet illustrates the XML nodes described in the above steps. Code:
<XomGenerator Include="$(XomegaHome)Xsl\model_enums_db.xsl">
<Name>Enumerations from Database</Name>
<Folder>Model Enhancement</Folder>
<OutputPath>ImportedEnums/_{Module}_enums.xom</OutputPath>
<AddOutputToProject>true</AddOutputToProject>
<IncludeInBuild>false</IncludeInBuild>
<Database>$(Database)</Database>
<DbCase>$(DbCase)</DbCase>
<DbConnection>$(DbConnection)</DbConnection>
<DbTimeout>$(DbTimeout)</DbTimeout>
<AddToProject-param>../MyProject/MyProject.Common.csproj</AddToProject-param>
<AddToProject-desc>A project file to add the generated files to.</AddToProject-desc>
<AddToProject-category>Output</AddToProject-category>
</XomGenerator>
|