VersaTul.Display.Attributes 1.0.9

Prefix Reserved
There is a newer version of this package available.
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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VersaTul.Display.Attributes" Version="1.0.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VersaTul.Display.Attributes --version 1.0.9                
#r "nuget: VersaTul.Display.Attributes, 1.0.9"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
1.0.11 222 12/10/2024
1.0.9 127 12/7/2024
1.0.8 993 2/25/2024
1.0.7 336 2/1/2024
1.0.6 722 1/15/2024
1.0.5 571 1/11/2024
1.0.4 969 7/22/2023