Skip to main content
.NET Framework 4.6.2+

EnumDescriptor.GenerateDefaultCaptions(IModelLocalizationGroup, Type) 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
)

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.

Remarks

Calling this GenerateDefaultCaptions method overload is equivalent to calling the GenerateDefaultCaptions method overload that takes the compoundNameConvertStyle parameter, with the CompoundNameConvertStyle.SplitAndCapitalization value.

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));
    }
}

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