YetAnotherConsoleTables.CommonConverters 1.1.0

dotnet add package YetAnotherConsoleTables.CommonConverters --version 1.1.0                
NuGet\Install-Package YetAnotherConsoleTables.CommonConverters -Version 1.1.0                
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="YetAnotherConsoleTables.CommonConverters" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YetAnotherConsoleTables.CommonConverters --version 1.1.0                
#r "nuget: YetAnotherConsoleTables.CommonConverters, 1.1.0"                
#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 YetAnotherConsoleTables.CommonConverters as a Cake Addin
#addin nuget:?package=YetAnotherConsoleTables.CommonConverters&version=1.1.0

// Install YetAnotherConsoleTables.CommonConverters as a Cake Tool
#tool nuget:?package=YetAnotherConsoleTables.CommonConverters&version=1.1.0                

YetAnotherConsoleTables.CommonConverters NuGet Made in Ukraine

The set of common table member converters for the YetAnotherConsoleTables library.

Converters

AppendValueConverter

Append a suffix to member values. Any object of attribute parameter types can be used as the suffix.

class Box
{
    [TableMemberConverter<AppendValueConverter>(ConstructorArgs = new[] { " kg" })]
    public double Weight { get; set; } = 100;
}
----------
| Weight |
----------
| 100 kg |
----------

PrependValueConverter

Prepend a prefix to member values. Any object of attribute parameter types can be used as the prefix.

class Box
{
    [TableMemberConverter<PrependValueConverter>(ConstructorArgs = new[] { "UAH: " })]
    public double Price { get; set; } = 1000;
}
-------------
| Price     |
-------------
| UAH: 1000 |
-------------

WrapValueConverter

Prepend a prefix and append a suffix to member values at the same time. You can achieve the same behavior with a ChainedConverter, but this one will run faster. Any objects of attribute parameter types can be used as the prefix and the suffix.

class Box
{
    [TableMemberConverter<WrapValueConverter>(ConstructorArgs = new[] { "UAH ", " per item" })]
    public int DiscountPerItem { get; set; } = 5;
}
-------------------
| DiscountPerItem |
-------------------
| UAH 5 per item  |
-------------------

FormattableConverter

Convert an object that implements IFormattable using the ToString() method of this interface.

class Box
{
    [TableMemberConverter<FormattableConverter>(ConstructorArgs = new[] { "P2" })]
    public double Discount { get; set; } = 0.05;
	
    [TableMemberConverter<FormattableConverter>(ConstructorArgs = new[] { "C2", "en-US" })]
    public double Price { get; set; } = 900;
}
----------------------
| Discount | Price   |
----------------------
| 5.00 %   | $900.00 |
----------------------

StringReplaceConverter

Find all occurrences of a specified string and replace them with another specified string.

class Box
{
    [TableMemberConverter<StringReplaceConverter>(ConstructorArgs = new[] { "<br/>", "\r\n" })]
    public string HtmlDescription { get; set; } = "Description<br/>Description";
}
-------------------
| HtmlDescription |
-------------------
| Description     |
| Description     |
-------------------

RegexReplaceConverter

Replace all strings that match a specified pattern with a specified replacement string.

class User
{
    [TableMemberConverter<RegexReplaceConverter>(ConstructorArgs = new[] { ".", "*" })]
    public string Password { get; set; } = "qwerty";
}
------------
| Password |
------------
| ******   |
------------

ChainedConverter

Combine two or more converters in a chain. Out of the box, converters are available that combine 2 to 5 other converters. If you need to combine more than 5 converters, the ChainedConverter can be nested in another.

class Box
{
    [TableMemberConverter<ChainedConverter<FormattableConverter, AppendValueConverter>>(ConstructorArgs = new object[] { new[] { "C" }, new[] { " per item" }})]
    public int Discount { get; set; } = 5;
}
------------------
| Discount       |
------------------
| �5.00 per item |
------------------

EnumerableFirstConverter

Use the first element of the IEnumerable. The first element can be retrieved using FirstOrDefault or First LINQ method.

class Student
{
    [TableMember(DisplayName = "First Mark")]
    [TableMemberConverter<EnumerableFirstConverter<string>>]
    public string[] Marks { get; set; } = new[] { "A", "A", "F" };
}
--------------
| First Mark |
--------------
| A          |
--------------

EnumerableLastConverter

Use the last element of the IEnumerable. The last element can be retrieved using LastOrDefault or Last LINQ method.

class Student
{
    [TableMember(DisplayName = "Last Mark")]
    [TableMemberConverter<EnumerableLastConverter<string>>]
    public string[] Marks { get; set; } = new[] { "A", "A", "F" };
}
------------
| Last Mark |
-------------
| F         |
-------------

EnumerableJoinConverter

Join all elements of the IEnumerable using the passed separator.

class Student
{
    [TableMemberConverter<EnumerableJoinConverter<string>>(ConstructorArgs = new object[] { ", " })]
    public string[] Marks { get; set; } = new[] { "A", "A", "F" };
}
-----------
| Marks   |
-----------
| A, A, F |
-----------
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 130 2/10/2024
1.0.0 165 6/17/2023

Added Enumerable converters: First, Last, Join.