If you have multiple Accelerator modules referencing the same code, you may need to condition in the code based on Module Number. An example would be that you want to load different preview pane sub modules based on the module number.
If you need to condition based on module number, I suggest that you centralize where you hard code the module numbers. This not only gives you insight into what modules you are conditioning on throughout your system, but also allows you to quickly change them if needed.
In this example, I want to load different preview sub modules in the content window and the detail based on whether the module is the Command Groups module or the User Groups module.
The best way to centralize the module numbers is to create an enum. So that it is accessible from anywhere, I would suggest you put the enum class in your system level BOS Shared project.
namespace BOS.AcceleratorShared { /// <summary> /// Class SharedEnums. /// </summary> public static class SharedEnums { /// <summary> /// Enum Modules /// </summary> public enum Modules { /// <summary> /// The command groups /// </summary> CommandGroups = 90000365, /// <summary> /// The user groups /// </summary> UserGroups = 90000074, } } }
Now that you have the enum, we can condition the preview sub modules in the content window and the detail by changing the ap_SubBrowserLoadID property.
In the content window, you can add the condition below to the RG_SetParentProperties() method. By default, the Accelerator will set the ap_SubBrowserLoadID property to the Content Window Class Name, so you only need to code if you want to change this default value. In the example below, we are changing it only if the module is Command Groups.
private void RG_SetParentProperties() { // Call Initialize Component im order to access XAML objects in Code Behind InitializeComponent(); ap_MainDetailType = typeof(UserGroupsDetail); // Visual State Manager _ViewModel = FindResource("UserGroupsViewModel") as UserGroupsViewModel; ap_ViewModel = _ViewModel; ap_DataMaps = new UserGroupsMaps().ap_FieldMaps; if (ap_ModuleEntity.IsModule(SharedEnums.Modules.CommandGroups)) { // Change SubBowser ID ap_SubBrowserLoadID = "RFWUGY01_COMMANDS"; } }
In the Detail, you will need to override the method am_CreateSubBrowsers and set the ap_SubBrowserLoadID property. By default, the Accelerator will set the ap_SubBrowserLoadID property to the Detail Window Class Name, so you only need to code if you want to change this default value. In the example below, we are changing it only if the module is Command Groups.
protected override void am_CreateSubBrowsers() { if (ap_ModuleEntity.IsModule(SharedEnums.Modules.CommandGroups)) { // Change SubBowser ID ap_SubBrowserLoadID = "FFWUGD01_COMMANDS"; } base.am_CreateSubBrowsers(); }
It has been a standard for us to use a different ap_SubBrowserLoadID for the Content Window vs. the Detail Window. This allows you to control what Tabs show in each tab control. There is no reason why you can't use the same ap_SubBrowserLoadID for both locations.
You just need to define each ap_SubBrowserLoadID by creating a Standard Base Interface Record for each Sub Module to show and View References to the Child Module so that it knows what View or Views to load.