VersaTul.Display.Attributes
1.0.9
Prefix Reserved
See the version list below for details.
dotnet add package VersaTul.Display.Attributes --version 1.0.9
NuGet\Install-Package VersaTul.Display.Attributes -Version 1.0.9
<PackageReference Include="VersaTul.Display.Attributes" Version="1.0.9" />
paket add VersaTul.Display.Attributes --version 1.0.9
#r "nuget: VersaTul.Display.Attributes, 1.0.9"
// Install VersaTul.Display.Attributes as a Cake Addin #addin nuget:?package=VersaTul.Display.Attributes&version=1.0.9 // Install VersaTul.Display.Attributes as a Cake Tool #tool nuget:?package=VersaTul.Display.Attributes&version=1.0.9
VersaTul Display Attributes
The VersaTul Display Attributes project enables the ability to provide meta-data to the export engine for outputting collections as files. This package works with the Collection Streamers package. Attributes can be applied to the properties of a collection data type in order to manipulate the outputted data.
Installation
To use VersaTul Display Attributes, first install it using nuget:
Install-Package VersaTul.DisplayAttributes
Usage
To use VersaTul Display Attributes, you need to import the namespace:
using VersaTul.DisplayAttributes;
Then, you can apply the DisplayAttribute
to the properties of your collection data type. For example:
public class Product
{
[Display(Name = "Product ID")]
public int Id { get; set; }
[Display(Name = "Product Name")]
public string Name { get; set; }
[Display(Decimal = 2)]
public decimal Price { get; set; }
[Display(DateFormattingString = "D")]
public DateTime DateAdded { get; set; }
}
The DisplayAttribute
provides meta-data to the export engine for outputting data to files. You can specify the following parameters:
Name
: The name of the property to be displayed on the file.Decimal
: The number of decimal places to round the property value on the file.DateFormattingString
: The formatting string for the property value on the file, using the standard date and time format specifiers.
You can also use the IFormatter
interface to create your own custom formatters for the property values. For example:
public class CurrencyFormatter : IFormatter
{
public object FormatValue(object value)
{
return string.Format("{0:C}", value);
}
}
public class Product
{
// ...
[Display(Formatter = typeof(CurrencyFormatter))]
public decimal Price { get; set; }
// ...
}
The IDisplayAnalyzer
interface specifies the functionality provided by a display analyzer. You can use the DisplayAnalyzer
class to access the display attributes of a given property. For example:
var analyzer = new DisplayAnalyzer();
var attribute = analyzer.GetAttribute(typeof(Product).GetProperty("Price"));
var name = analyzer.GetName(typeof(Product).GetProperty("Price"));
var value = analyzer.FormatValue(typeof(Product).GetProperty("Price"), 19.99m);
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
-
net6.0
- VersaTul.Pipeline.Infrastructure (>= 1.0.22)
-
net7.0
- VersaTul.Pipeline.Infrastructure (>= 1.0.22)
-
net8.0
- VersaTul.Pipeline.Infrastructure (>= 1.0.22)
-
net9.0
- VersaTul.Pipeline.Infrastructure (>= 1.0.22)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on VersaTul.Display.Attributes:
Package | Downloads |
---|---|
VersaTul.Object.Converters
The VersaTul Object Converters project provides the ability to convert objects into key/value pairs dictionary stores. For example, converters can be used to convert instance of classes into a dictionary representation of the data from the class. This package works with the Collection streamers package. |
GitHub repositories
This package is not used by any popular GitHub repositories.