Skip to main content
.NET 8.0+

EnumDescriptor.GenerateDefaultCaptions(IModelLocalizationGroup, Type, CompoundNameConvertStyle) Method

Generates LocalizationItem nodes corresponding to the values of an enumeration.

Namespace: DevExpress.ExpressApp.Utils

Assembly: DevExpress.ExpressApp.v24.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public static void GenerateDefaultCaptions(
    IModelLocalizationGroup nodeGroup,
    Type enumType,
    CompoundNameConvertStyle compoundNameConvertStyle
)

Parameters

Name Type Description
nodeGroup IModelLocalizationGroup

An IModelLocalizationGroup object representing the LocalizationGroup node where LocalizationItem child nodes will be created.

enumType Type

A Type object representing the enumeration for which LocalizationItem nodes will be generated.

compoundNameConvertStyle CompoundNameConvertStyle

A CompoundNameConvertStyle enumeration value specifying how enumeration values are converted into the LocalizationItem nodes’ IModelLocalizationItem.Value property values.

Remarks

Since localization nodes for enumerations used as types of persistent properties are automatically generated, generally, you do not need to use the GenerateDefaultCaptions method. Nevertheless, you can use this method to create localization nodes for an arbitrary enumeration by implementing a Generator Updater. The following code snippet illustrates this.

using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Model.Core;
using DevExpress.ExpressApp.Model.NodeGenerators;
//...
public enum MyEnum {
    FirstEnumValue,
    SecondEnumValue
}
public class MyEnumUpdater : ModelNodesGeneratorUpdater<ModelLocalizationNodesGenerator> {
    public override void UpdateNode(ModelNode node) {
        EnumDescriptor.GenerateDefaultCaptions(node["Enums"].AddNode<IModelLocalizationGroup>(
            typeof(MyEnum).FullName), typeof(MyEnum), 
            CompoundNameConvertStyle.SplitAndCapitalization);
    }
}

To register the Generator Updater, the ModuleBase.AddGeneratorUpdaters method should be overridden.

public sealed partial class MyModule : ModuleBase {
    //...
    public override void AddGeneratorUpdaters(
        DevExpress.ExpressApp.Model.Core.ModelNodesGeneratorUpdaters updaters) {
        base.AddGeneratorUpdaters(updaters);
        updaters.Add(new MyEnumUpdater());
    }
}

This will generate a new group under the Localization | Enums node.

EnumDescriptor_GenerateDefaultCaptions

See Also