Apart from validation, there are some attributes that can be applied to Properties to control format and change tracking.
All this Attributes have been included in Signum Framework 2.0
HiddenPropertyAttribute
Applied to a property, prevent it from being validated, and appear in some automatic UI.
[AttributeUsage(AttributeTargets.Property)]
public class HiddenPropertyAttribute : Attribute
{
}
UnitAttribute
Applied to a property of a (usually) numeric type indicates the unit symbol of the measure. This information could be used by ValueLine as well as included in the format of the tables of a SearchWindow's result panel.
[AttributeUsage(AttributeTargets.Property)]
public class UnitAttribute : Attribute
{
public string UnitName { get; }
public UnitAttribute(string unitName)
}
Example:
int progress;
[Unit("%")]
public int Progress
{
get {...}
set {...}
}
Then in the User interface a readonly % symbol will appear at the right side of the ValueLines and SearchControl results.
FormatAttribute
Applied to a property of numeric type or DateTime, indicates the format that should be used by the UI to show the property value. This information could be used by ValueLine as well as included in the format of the tables of a SearchWindow's result panel.
[AttributeUsage(AttributeTargets.Property)]
public class FormatAttribute : Attribute
{
public string Format { get;}
public FormatAttribute(string format)
}
Example:
int ratio;
[Format("0.0000")]
public double Ratio
{
get {...}
set {...}
}
Then 4 decimals will be used to represent the ratio whenever is shown to the user.
ReloadEntityOnChange
Indicates that a property's setter will make changes in other properties. This information is necessary for Signum.Web.
[AttributeUsage(AttributeTargets.Property)]
public sealed class ReloadEntityOnChange : Attribute
{
}
Reactive
Indicates that an entity has some properties decorated with ReloadEntityOnChange.
[AttributeUsage(AttributeTargets.Class)]
public sealed class Reactive : Attribute
{
}
Descriptions
Finally, it's possible to change the default name that properties have in the user interface. See in
DescriptionAttributes.