Skip to content

configuration options

vijay@envivo edited this page Jul 11, 2024 · 15 revisions

Configuration Attributes & Options

See the Model Configuration Attributes and Model Configuration Classes sections to see how these configurations are applied to your model.

These options are used to configure UI display and behaviour:

Envivo.Fresnel.ModelAttributes.AllowedOperationsAttribute

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method)]
Property Description Type Default
CanCreate Determines if user the can create instances of the class bool true
CanRead Determines if user the can read the property bool true
CanModify Determines if user the can edit the property bool true
CanAdd Determines if user the can add objects to the property bool true
CanRemove Determines if user the can remove objects from the property bool true
CanClear Determines if user the can clear the property bool true
CanInvoke Determines if user the can invoke the method bool true

Envivo.Fresnel.ModelAttributes.CollectionAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
Property Description Type Default
AddMethodName The name of the Method that adds an item to the collection string
CanExpandRows Determines if collection tables support inline row expansion bool false
RemoveMethodName The name of the Method that removes an item from the collection string
VisibleColumnNames Only shows columns that match the named properties in this array string[]

Envivo.Fresnel.ModelAttributes.FilterQuerySpecificationAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
Property Description Type Default
SpecificationType The QuerySpecification used to populate a selection list for the user to select from. Type

Envivo.Fresnel.ModelAttributes.MethodAttribute

[AttributeUsage(AttributeTargets.Class)]
Property Description Type Default
RelatedPropertyName The name of the Property that the method should be rendered against string
MandatoryPromptText Displays this text before the method is invoked string
UnsavedChangesPromptText Displays this text if the parent object has unsaved changes string

Envivo.Fresnel.ModelAttributes.HiddenMembersAttribute

[AttributeUsage(AttributeTargets.Class)]
Property Description Type Default
Names A list of property names that should be hidden in the UI. Note that this is a global list, and applies to all classes/members within your model string[]

Envivo.Fresnel.ModelAttributes.RelationshipAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
Property Description Type Default
Type Determines whether objects can be created or added to a property (or collection). See Object Properties and Collection Properties for examples. RelationshipType Has

RelationshipType values

Value Description
Has (aka Aggregation) This object is related to the property's content(s). Deleting this object will not affect these contents.
Owns (aka Composition) This object owns the properties content(s) . Deleting this object should delete the contents too.
OwnedBy This object is owned by the property's content. This is only relevant for objects, not collections.

Envivo.Fresnel.ModelAttributes.RelationalQuerySpecificationAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
Property Description Type Default
SpecificationType The QuerySpecification used to load the content of the associated Collection property. Aka on-demand or lazy-loading. Type

Envivo.Fresnel.ModelAttributes.UIAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
Property Description Type Default
RenderOption Determines how the object property is rendered in the panel UiRenderOption SeparateTabExpanded
PreferredControl Uses a specific HTML control to render the property or parameter UiControlType None
TrueValue The text value to use for boolean TRUE string "Yes"
FalseValue The text value to use for boolean FALSE string "No"
DecimalPlaces The number of decimal places to show for decimal and float numbers int 3

UiRenderOption values

Value Description
InlineSimple The object is show as a single entry
InlineExpanded The object's properties are expanded
SeparateTabExpanded The object's properties are shown in a separate tab

UiControlType values

Note: These only work if:

  • the Fresnel UI supports the HTML5 control
  • the applied property or parameter has a suitable type
Values
Checkbox Color Currency Date DateTimeLocal Email File
Html Image Month Number Password PostalCode Radio
Range Search Select Switch Telephone Text TextArea Time
TimeDuration Upload Url Week

Envivo.Fresnel.ModelAttributes.VisibilityAttribute

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Parameter)]
Property Description Type Default
IsVisible Determines if the class or member is visible in the UI bool true
IsVisibleInLibrary Determines if the class is shown in the Library panel bool true

Envivo.Fresnel.ModelAttributes.VisualIdentifierAttribute

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Parameter)]
Property Description Type Default
HtmlColour The HTML colour to be used string
IconHtml The emoji or icon to be shown string

System.ComponentModel Attributes

These attributes are provided by the .NET framework. Please refer to the .NET documentation for more details.

System.ComponentModel.DataAnnotations.KeyAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]

Required on the Id property, to uniquely identify an object.

System.ComponentModel.DataAnnotations.ConcurrencyCheckAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]

Required on the Version property, to so that the underlying data provider can perform optimistic concurrency checks.

System.ComponentModel.DataAnnotations.DataTypeAttribute

[AttributeUsage(
AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Parameter,
AllowMultiple = false)]

System.ComponentModel Attributes

These attributes are provided by the .NET framework. Please refer to the .NET documentation for more details.

System.ComponentModel.DataAnnotations.KeyAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]

Required on the Id property, to allow it to be persisted via it's IRepository.

System.ComponentModel.DataAnnotations.ConcurrencyCheckAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]

Required on the Version property, to so that the underlying data provider can perform optimistic concurrency checks.

System.ComponentModel.DataAnnotations.DefaultValueAttribute

[AttributeUsage(AttributeTargets.All)]
Property Description Type Default
value The default values used for the property/parameter in the UI Any

It is also possible to provide values that are calculated at run-time. In this example, we specify an IValueProvider that returns the current date/time:

First, create a custom Value Provider:

using Envivo.Fresnel.ModelTypes.Interfaces;

public class DateTimeValueProvider : IValueProvider<object, DateTime>
{
    public DateTime GetValue(object context) => DateTime.Now;
}

Now apply the 'DefaultValueAttribute' to the property:

[DefaultValue(typeof(DateTimeValueProvider)]
public DateTime OrderPlacementDate { get; set; }

At run-time, the DateTimeValueProvider will be used whenever the property appears for a transient instance.

System.ComponentModel.DataAnnotations.DisplayAttribute

[AttributeUsage(
AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Class,
AllowMultiple = false)]
Property Description Type Default
AutoGenerateField Determines if the property/parameter is visible in the UI bool true
DisplayName Overrides the name shown in the UI string
GroupName Members that share the same GroupName value will appear together string
Order Used to enforce the sequence of members in the UI integer
Prompt The text to show when the UI field is empty string

System.ComponentModel.DataAnnotations.DisplayFormatAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
Property Description Type Default
DataFormatString The format string for rendering the property/parameter value string

System.ComponentModel.DataAnnotations.DisplayNameAttribute

[AttributeUsage(
AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Method | AttributeTargets.Class,
AllowMultiple = false)]
Property Description Type Default
Name Same as DisplayAttribute.DisplayName string

System.ComponentModel.DataAnnotations.MaxLengthAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter,
AllowMultiple = false)]
Property Description Type Default
Length The maximum allowed length of the string property/parameter int 0

System.ComponentModel.DataAnnotations.MinLengthAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter,
AllowMultiple = false)]
Property Description Type Default
Length The minimum allowed length of the string property/parameter int 0

System.ComponentModel.DataAnnotations.RangeAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter,
AllowMultiple = false)]
Property Description Type Default
Minimum The minimum value allowed on the numeric property/parameter int/double 0
Maximum The maximum value allowed on the numeric property/parameter int/double 0
ErrorMessage A custom message to show if the validation fails string

System.ComponentModel.DataAnnotations.RequiredAttribute

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]

Used on properties or parameters whose values are mandatory.

Clone this wiki locally