### Adding EnableRoleGeneratorAction Key to App.config (XML) Source: https://github.com/devexpress-examples/xaf_how-to-get-role-code-from-the-ui/blob/24.2.1+/Readme.md Shows how to add the `EnableRoleGeneratorAction` key with a value of "True" within the `` section of an `App.config` file to enable the role generator action in a WinForms XAF application. ```XML ... ``` -------------------------------- ### Adding EnableRoleGeneratorAction Key to appsettings.json (JSON) Source: https://github.com/devexpress-examples/xaf_how-to-get-role-code-from-the-ui/blob/24.2.1+/Readme.md Demonstrates how to add the `EnableRoleGeneratorAction` key with a value of "True" to an `appsettings.json` file, typically used in ASP.NET Core Blazor XAF applications, to enable the role generator action. ```JSON "EnableRoleGeneratorAction": "True", ``` -------------------------------- ### Handle RoleGenerator.CustomizeCodeLines in C# Source: https://github.com/devexpress-examples/xaf_how-to-get-role-code-from-the-ui/blob/24.2.1+/Readme.md Demonstrates how to handle the CustomizeCodeLines event of the RoleGenerator to add custom properties from an ExtendedSecurityRole object to the list of code lines that will be generated. This allows including custom role-specific settings in the generated updater code. ```C# // C# using System.Collections.Generic; using System.Linq; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Actions; using DevExpress.Persistent.Base; using RoleGeneratorSpace; namespace XafSolution.Module.Controllers { public abstract class RoleGeneratorController : ViewController { //... protected void RoleGeneratorAction_Execute(object sender, SimpleActionExecuteEventArgs e) { RoleGenerator roleGenerator = new RoleGenerator(roleType); roleGenerator.CustomizeCodeLines += RoleGenerator_CustomizeCodeLines; IEnumerable roleList = e.SelectedObjects.OfType(); string updaterCode = roleGenerator.GetUpdaterCode(roleList); SaveFile(updaterCode); } private void RoleGenerator_CustomizeCodeLines(object sender, CustomizeCodeLinesEventArg e) { ExtendedSecurityRole exRole = e.Role as ExtendedSecurityRole; if(exRole != null) { e.CustomCodeLines.Add(string.Format("role.CanExport = {0};", exRole.CanExport.ToString().ToLowerInvariant())); } } } } ``` -------------------------------- ### Including Custom RoleUpdater in XAF Module (C#) Source: https://github.com/devexpress-examples/xaf_how-to-get-role-code-from-the-ui/blob/24.2.1+/Readme.md Illustrates how to modify the `GetModuleUpdaters` method in a XAF module's `Module.cs` file to include a custom `RoleUpdater` alongside the default `DatabaseUpdate.Updater`, allowing for custom database update logic, such as initializing roles. ```C# // C# using System; using DevExpress.ExpressApp; using System.Collections.Generic; using DevExpress.ExpressApp.Updating; namespace YourSolutionName.Module { public sealed partial class YourSolutionNameModule : ModuleBase { public override IEnumerable GetModuleUpdaters(IObjectSpace objectSpace, Version versionFromDB) { ModuleUpdater updater = new DatabaseUpdate.Updater(objectSpace, versionFromDB); ModuleUpdater roleUpdater = new RoleUpdater(objectSpace, versionFromDB); return new ModuleUpdater[] { updater, roleUpdater }; //... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.