Display Attributes
Overview
VersaTul.Display.Attributes lets you annotate model properties with export metadata such as display name, ordering, numeric precision, date formatting, and ignore rules.
The package is most useful when paired with Collection Streamers, where those annotations influence the shape and formatting of exported output.
When To Use This Package
Use this package when you want to:
Rename columns during export without renaming your model properties.
Control export column order.
Round decimal values during output generation.
Format date values with a display-specific format string.
Exclude properties from exported output.
Installation
Install the package with the .NET CLI:
dotnet add package VersaTul.Display.Attributes
Or with the Package Manager Console:
PM> NuGet\Install-Package VersaTul.Display.Attributes -Version latest
Core Types And Concepts
DisplayAttributeAttribute used to control exported name, sequence, decimal precision, date formatting, culture, and ignore behavior.
IDisplayAnalyzerandDisplayAnalyzerRead display metadata from reflected properties and format values using registered formatters.
IFormatterFormatter contract used by the display pipeline.
DateFormatterandDecimalFormatterBuilt-in formatters for date and numeric output.
Key Capabilities
Override the exported property name with
Name.Control output order with
Sequence.Round numeric values with
Decimals.Format
DateTimevalues withDateFormattingStringand optionalCultureName.Exclude members from output with
Ignore.Register additional custom formatters through
DisplayAnalyzer.RegisterFormatter().
Attribute Example
using VersaTul.Display.Attributes;
public class Order
{
public int OrderId { get; set; }
[Display(Name = "Shipping Method", Sequence = 1)]
public string ShipVia { get; set; }
[Display(Decimals = 2, Sequence = 2)]
public decimal SubTotal { get; set; }
[Display(DateFormattingString = "D", Sequence = 3)]
public DateTime OrderDate { get; set; }
[Display(Ignore = true)]
public bool InternalFlag { get; set; }
}
Analyzer Example
var analyzer = new DisplayAnalyzer();
var property = typeof(Order).GetProperty(nameof(Order.OrderDate));
var display = analyzer.GetAttribute(property);
var formatted = analyzer.FormatValue(display, DateTime.UtcNow);
Notes
DisplayAnalyzer.PropertyNamesreturns resolved export names ordered by sequence and then name.The analyzer caches resolved property metadata internally as names are requested.
Custom formatters are the extension point when you need export-specific formatting beyond the built-ins.