ZayniFramework.Formatting 2.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ZayniFramework.Formatting --version 2.3.0
                    
NuGet\Install-Package ZayniFramework.Formatting -Version 2.3.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="ZayniFramework.Formatting" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZayniFramework.Formatting" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="ZayniFramework.Formatting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZayniFramework.Formatting --version 2.3.0
                    
#r "nuget: ZayniFramework.Formatting, 2.3.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.
#:package ZayniFramework.Formatting@2.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZayniFramework.Formatting&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=ZayniFramework.Formatting&version=2.3.0
                    
Install as a Cake Tool

Formatting module example.

Add Formatting section in your app.config or web.config file if you are going to do some DateTime formatting.

<FormattingSettings>
    <DateTimeFormatStyle>
        <add language="zh-TW" format="yyyy/MM/dd" isDefault="true"/>
        <add language="zh-CN" format="yyyy/MM/dd"/>
        <add language="en-US" format="MM-dd-yyyy"/>
    </DateTimeFormatStyle>
</FormattingSettings>

Then you can add the Formatting Attribute in your Properties.

using ZayniFramework.Formatting;

public class MasterModel : BasicModel<MasterVModel>
{
    // For deep formatting
    [CollectionFormat()]
    public List<DetailModel> Details { get; set; }
    
    public string Name { get; set; }

    [DateFormat()]
    public DateTime Birthday { get; set; }

    [NumberFormat( Length = 2 )]
    public decimal Age { get; set; }
    
    [CollectionFormat()]
    public DetailInfoModel DetailInfo { get; set; }
}

public class MasterVModel : BasicViewModel
{
    public string Name { get; set; }

    public string Birthday { get; set; }

    public string Age { get; set; }

    // In the ViewModel only suppory 'String' property.
    //public DetailInfoModel DetailInfo { get; set; }
}

Finally, you can format the Model class like this:

// Test data here...
var model = new MasterModel();

model.Name       = "John";
model.Birthday   = new DateTime( 1988, 1, 1 );
model.Age        = 16;
model.DetailInfo = new DetailInfoModel() 
{ 
    InfoName = "JJJ", 
    NAVDate  = new DateTime( 2013, 5, 7 ) 
};
model.Details = new List<DetailModel>() 
{
    new DetailModel 
    {
        DetailName       = "IUIU",
        Length          = 3M,
        Pay             = 45673.52434M,
        NavDate         = new DateTime( 2013, 3, 5 ),
        Name            = "Joe",
        MaskStartIndex  = 1,
        MaskLength      = 1,
        Name2           = "Jimmy"
    },
    new DetailModel 
    {
        DetailName      = "Jack",
        Length          = 2M,
        Pay             = 785.5497M,
        NavDate         = new DateTime( 2013, 7, 5 ),
        Name            = "Kindding",
        MaskStartIndex  = 2,
        MaskLength      = 3,
        Name2           = "Ruby"
    }
};

// do the format here...
var viewModelType = typeof( MasterVModel );
var formatter     = new DataFormatter();
var result        = formatter.DoModelDeepFormat( model, viewModelType );

// get the format result here...
MasterModel  resultModel  = (MasterModel)result;
MasterVModel resultVModel = resultModel.ViewModel;

Or you can also use the Dynamic Formatting.

Then, you don't have to define a ViewModel class anymore. But the dynamic formatting is a little slower than using ViewModel formatting.

// Your class will extend the BasicDynamicModel instead of BasicModel
public class MasterModel2 : BasicDynamicModel
// Use dynamic formatting here...
var formatter = new DataFormatter();
object result = formatter.FormatDynamicModel( model );

// Get the dynamic formatting here...
MasterModel2 resultModel  = (MasterModel2)result;
dynamic      resultVModel = resultModel.ViewModel;  // dynamic type
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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
8.0.142 259 3/19/2024
8.0.141 239 1/4/2024
8.0.140 184 12/17/2023
6.0.138 215 3/19/2024
6.0.137 206 9/20/2023
6.0.136 211 9/14/2023
6.0.135 205 9/10/2023
6.0.134 244 7/12/2023
6.0.133 263 7/10/2023
6.0.132 251 7/7/2023
6.0.131 268 6/19/2023
6.0.130 231 6/19/2023
6.0.129 636 7/2/2022
6.0.128 669 1/16/2022
6.0.127 646 1/15/2022
6.0.126 657 1/15/2022
6.0.125 452 1/8/2022
6.0.125-hotfix1 334 1/8/2022
6.0.124 452 1/7/2022
6.0.123 582 11/14/2021
5.0.129 684 7/2/2022
5.0.128 656 1/16/2022
5.0.125 479 1/8/2022
5.0.124 449 1/7/2022
5.0.123 669 11/14/2021
5.0.122 662 10/11/2021
5.0.121 676 5/1/2021
3.1.137 185 9/20/2023
3.1.136 183 9/14/2023
3.1.135 209 9/10/2023
3.1.134 252 7/12/2023
3.1.133 255 7/11/2023
3.1.132 247 7/8/2023
3.1.131 303 6/19/2023
3.1.130 471 2/1/2023
3.1.129 648 7/2/2022
3.1.128 641 1/16/2022
3.1.125 469 1/8/2022
3.1.124 471 1/7/2022
3.1.123 646 11/14/2021
3.1.122 606 10/11/2021
3.1.121 579 5/1/2021
2.31.120 601 3/14/2021
2.30.115 643 3/6/2021
2.30.114 577 3/6/2021
2.20.101 567 3/1/2021
2.19.3 583 2/11/2021
2.19.2 640 2/6/2021
2.19.1 700 1/6/2021
2.19.0 622 1/1/2021
2.18.3 787 12/27/2020
2.18.2 735 8/29/2020
2.18.1 778 8/26/2020
2.18.0 780 8/20/2020
2.17.135 715 8/19/2020
2.17.134 841 7/28/2020
2.17.133 805 7/27/2020
2.17.132 825 7/18/2020
2.17.131 742 7/11/2020
2.16.130 838 6/13/2020
2.15.128 774 6/3/2020
2.15.127 825 5/31/2020
2.15.126 857 4/30/2020
2.14.122 771 4/13/2020
2.13.100 787 3/12/2020
2.12.51 764 2/18/2020
2.11.50 1,467 2/10/2020
2.10.44 1,472 1/30/2020
2.9.43 1,583 1/11/2020
2.8.42 1,593 1/10/2020
2.8.41 1,488 1/5/2020
2.7.40 1,483 1/2/2020
2.7.39 1,526 1/2/2020
2.7.38 1,747 1/1/2020
2.6.37 1,496 12/23/2019
2.6.35 1,460 12/4/2019
2.6.1 1,508 12/2/2019
2.6.0 1,496 11/28/2019
2.5.2 1,749 11/26/2019
2.5.1 1,536 11/12/2019
2.5.0 1,560 11/9/2019
2.4.3 1,040 10/16/2019
2.4.2 1,028 10/16/2019
2.4.1 1,086 9/20/2019
2.3.113 545 3/6/2021
2.3.112 576 3/6/2021
2.3.28 1,061 9/19/2019
2.3.27 1,054 8/30/2019
2.3.26 1,251 8/20/2019
2.3.25 1,094 8/12/2019
2.3.22 1,316 7/31/2019
2.3.21 1,065 7/20/2019
2.3.20 1,137 6/22/2019
2.3.19 993 6/14/2019
2.3.18 1,224 6/13/2019
2.3.17 1,071 6/13/2019
2.3.15 1,142 6/8/2019
2.3.14 1,196 6/8/2019
2.3.13 1,104 5/30/2019
2.3.12 828 5/24/2019
2.3.11 837 5/24/2019
2.3.10 839 5/21/2019
2.3.9 861 5/9/2019
2.3.8 828 5/8/2019
2.3.7 862 4/30/2019
2.3.6 914 4/23/2019
2.3.5 933 4/19/2019
2.3.4 905 4/18/2019
2.3.3 920 4/17/2019
2.3.2 891 4/6/2019
2.3.1 997 12/15/2018
2.3.0 1,007 12/7/2018
2.2.6 1,077 11/25/2018
2.2.1 1,012 11/17/2018
2.2.0 996 11/16/2018
2.1.0 987 11/15/2018
2.0.1 982 11/6/2018
2.0.0 1,099 11/4/2018