-
Notifications
You must be signed in to change notification settings - Fork 0
Member Format Expressions
Using CodeModeler, you can use “Member Format Expressions” to customize the way names of entities and properties are displayed in the design surface. The access is in the “Modeler Pad” ribbon tab:
Several expressions are provided by default, but you can also define your own expressions by selecting “Choose” (you do this from the “Modeler Tab” of the ribbon or from the contextual menu):
Clicking “Add New” will allow you to define your own:
Here we define an expression displaying the property name and indicating if the property is a key between parenthesis. Here is the result on entity shapes:
If you prefix your property path with a ‘#’, the value will be “decamelized” as shown in the image. For instance, the expression {Name} (IsKey={IsKey})
will display this (the difference is visible on the Line1 and Line2 properties):
Member Format Expression also supports “tags” (as in HTML). Three tags are supported in expressions:
-
Font: use it to define styles in your expression,
-
If: use it to define conditions,
-
Else: same as if.
For instance, specifying the following expression <font color="blue">{#Name}</font>
will display the entity shape like this:
But we can use the If tag like this <if condition=IsKey><font color="red">{#Name}</font><else/><font color="#00FFFF">{#Name}</font></if>
and this is how the shape will be displayed:
To ensure expressions don’t get too long the Font tag also has a condition attribute so you don’t necessarily have to wrap it in an If tag. Therefore, you could get the same result using this expression <font condition=IsKey color="red">{#Name}<else/><font color="#00FFFF">{#Name}</font></font>
.
The Font tag supports the following attributes:
-
family: takes a font family name (e.g. Lucida Console),
-
size: a font size in pt,
-
stretch: a font stretch (System.Windows.FontStretch),
-
style: a font style (System.Windows.FontStyle),
-
weight: a font weight (System.Windows.FontWeight),
-
color: a color (can take a value from System.Windows.Media.Brushes, or a #RGB value, or a #ARGB),
-
decorations: a comma separated list of System.Windows.TextDecorations,
-
trimming: a text trimming (System.Windows.TextTrimming),
-
alignment: a text alignment (System.Windows.TextAlignment),
-
direction: a flow direction (System.Windows.FlowDirection),
-
lineheight: a line height,
-
maxwidth: a maximum text width,
-
maxheight: a maximum text height,
-
maxlinecount: a maximum line count,
-
condition: a condition to be evaluated.
The condition attribute supports the following operators:
-
== or = for a case-insensitive equals,
-
[=CS] for a case-sensitive equals,
-
!=, \<\> for a case insensitive not equals,
-
[!=CS] for a case sensitive not equals,
-
\>= for greater than equals,
-
\<= for lower than equals,
-
\> for greater than,
-
\< for lower than,
-
[StartsWith] for a case-insensitive starts with,
-
[StartsWithCS] for a case-sensitive starts with,
-
[EndsWith] for a case-insensitive ends with,
-
[EndsWithCS] for a case-sensitive ends with,
-
[Contains] for a case-insensitive contains,
-
[ContainsCS] for a case-sensitive contains.
For example, here’s how to highlight all properties ending with “Id”: <font condition="Name [EndsWith] 'Id'" color='red'>{#Name}<else/>{#Name}</font>
Note: don’t forget to surround the right-side statement with quotes so the evaluator knows it’s a string.
There are also shortcuts such as you don’t have to specify > 0 for numbers, for instance this expression {#Name}<font condition='AllRules.Count' color='#007F0E'> (Rules={AllRules.Count})</font>
will suffix properties with (Rules=X) in green::
Note: Use member format expressions with caution as they’ll be evaluated for all property names, so the lighter they are, the better rendering performances will be and vice versa.
The MessagesBrowser class is a dynamic class you can use as a property path in Member Format Expressions which allows you to access messages (resources) defined for the current concept (entity or property).
For instance, if you defined English resources for each of your address properties in the documentation (“_doc”) class, like this:
Using this expression {#Name} ({MessagesBrowser._doc.en-US})
, you can use them directly in the property line like this:
Note: For performance results the* MessagesBrowser *class is cached and built on first access, so that defining a new resource or editing one will not be reflected immediately on the surface.
Thanks to the extensibility of the CodeModeler, you can customize your working environment to fit your need. With the property member format, you can visualize lots of information about your model very quickly.
Let’s suppose you have defined this entity in your model:
Then, using this Member Format Expression:
<if condition=IsEntityDisplay>-> </if> <if condition=IsNullable>({Name})<else />{Name}</if> : {DisplayTypeName} <if condition="'true'=Element.GetAttribute('localizable','http://www.softfluent.com/cm/aspects/localization/2018/1')">(Localizable)</if> <if condition=Relations.Count>({CascadeDelete})</if>
Entity shapes will look like this:
-
The icon indicates the property is a member of the primary key
-
Parentheses indicate the property is nullable
-
"(Localizable)" indicates the property is localizable when using the Localization aspect
-
"->" indicates the property is the “entity display name” property
-
The icon indicates the property type is an enumeration
-
"(None)", "(Before)" or "(After)" indicates the selected Cascade Delete option of the relation
-
"*" the infinite symbol indicate the property type is a collection
- 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