(These steps apply to any pattern, using the SDK provider under GeneXus X or X Evolution 1. Work With is only used as a concrete example).
In order to create a new pattern, not from scratch but starting from an existing one, you should follow these steps:
- Make a copy of the entire folder containing the pattern source files and templates (i.e. <SDK>\Patterns\WorkWith).
- Edit the pattern definition file (WorkWith.Pattern) and change at least the following attributes in the root element: Publisher, Name, Id. Publisher and Name must be valid C# identifiers since they will be used when constructing the namespace of the generated classes. Id can be any random GUID (please make sure to generate it from scratch, instead of just changing some bits in the existing one). Also change the format string for instance names (under Definition/InstanceName).
- Rename the C# Project (normally as <Provider>.Patterns.<Name>.csproj, but any name will do) and open it. Then change the Assembly Name property (in Project settings) so that the generated DLL has the same name.
- IMPORTANT: In the WorkWithPattern.cs file, change the GUID returned in the Id property so that it matches the GUID set in the definition file (Step 2).
- Build the project once. The pattern code generator will regenerate the definition classes (files WorkWithInstance.cs, WorkWithSettings.cs, WorkWithObjects.cs). There will be many errors in this build since namespaces will be inconsistent throughout the project files.
- OPTIONAL: If you want to use new names for the generated files, edit the pre-build events (Project > Properties > Build Events > Pre-build event command line) and change the "$(ProjectDir)WorkWith*" occurrences there. Then replace the previous files in the project with the new ones.
- Replace all namespaces in the project with the new ones (global search and replace should do).
- Replace all instances of WorkWithInstance, WorkWithSettings, WorkWithObject and IWorkWithInstanceElement with the new pattern definition
- OPTIONAL: Renaming other definition files (i.e. WorkWithInstance.xml, WorkWithSettings.xml, &c) is not necessary but would be a good idea for consistency.
- Check the catalog.xml file located in the project folder and modify it according to your name changes. This file is used to place the compiled pattern and dependencies under the GeneXus installation.
- Change OUTPUT_ID_RWD constant in WorkWithBuildProcess.cs to another number. This is to avoid an error when the pattern is loaded.
Workaround: In GX Evolution 1 (and U1), there is a "circular" dependence between the Pattern code generator and the pattern DLL. This means that to compile the project for the first time, the pattern definition file must not reference the helper dll: just remove it from the pattern definition file, then compile the assembly and re-add it. This will be fixed for U2.
After you start making your changes to the new pattern, remember that:
- If you want to change the basic resources (i.e. TabbedView, images, security procedure shells, &c) it would be a good idea to rename them, so as not to create conflicts if the standard Work With pattern is applied in the same Knowledge Base.
- In particular, the ListPrograms procedure references a Work With template. If you want to change it, modify the WorkWithResources.xml file directly.
To "deploy" the pattern, just copy its files to a folder under <GX installation>\Packages\Patterns, respecting the same directory structure as the Work With pattern.
If the Pattern is not shown in GeneXus, please enable the GeneXus Trace to get detailed data.