-
Notifications
You must be signed in to change notification settings - Fork 0
Enumerations
The enumeration concept in SoftFluent CodeModeler corresponds to the .NET one: it allows an architect to declare an enumeration of static values. Declaring an enumeration in the model outcomes in the generation of a standard .NET enumeration with the defined values in the Business Object Model (BOM) and other outputs.
Built-in enumeration support in CodeModeler means:
-
Being able to create your own enumerations (byte, sbyte, int, uint, short, ushort, long, ulong), at design time, with field localization support,
-
Being able to use multi-value enums (i.e: Flags enums in .NET terms),
-
Use already existing .NET enumerations.
Here is a sample Gender enumeration in the design surface, containing 3 names/values, used as a property of a Customer entity:
In the persistence layer, entities containing enumeration properties will directly store the corresponding enumeration value in their column. At run time, this value will automatically be converted to the equivalent .NET enumeration value upon load/save.
SoftFluent CodeModeler supports single value .NET enumerations as well as multi-valued ones (also known as Flags). To create a multi-value enumeration, you must set the “Multi Value” attribute to True in the Visual Studio property grid:
Note: You can set the Multi Value attribute after having created all the values, but it’s better to set it before. This way, when you add a new value to the enumeration, CodeModeler automatically proposes powers of 2 instead of incrementals.
Existing enumerations in a .NET assembly can be easily reused. For example, here we use System.DayOfWeek as the type for a Day property:
To understand how to reuse .NET types in external assemblies, consult the Reusing .NET Types chapter.
// Enumeration : Gender
public enum Gender
{
Unknown,
Female,
Male
}
// Enumeration with Flags attribute: CarOptions
[System.FlagsAttribute()]
public enum CarOptions
{
None = 0,
GPS = 1,
Radio = 2,
BabySeat = 4,
AC = 8,
CD = 16
}
As you can see in the example above, CodeModeler automatically sets proper values to support the flags behavior. Of course, you can override default values by setting your desired ones in the model and generating over.
Each entity and enumeration can be given a “category”. A category is just a name, or a path composed of names separated by dots. The list of categories in a project is defined implicitly by categories given to its types. See the Entities chapter for an example.
Categories are a way of grouping concepts, programmatically or visually in Visual Studio.
- Introduction
- Architect Guide
- Concepts
- Using Visual Studio
- Overview
- Creating a CodeModeler Project
- Visual Environment
- Project Hierarchy
- Design Surface
- Customizing Design Surfaces
- Ribbon Bar
- Property Grid
- Member Format Expressions
- Model Grid
- Method Editor
- View Editor
- Instance Editor and Grid
- Resources Editor
- Inferred Model Viewer
- Building
- Project Physical Layout
- Source Control Support
- Generating
- Aspect Oriented Design (AOD)
- Developer Guide
- The Business Object Model (BOM)
- CodeModeler Query Language (CMQL)
- Starting Guide - Tutorial
- Upgrade From CFE