VersaTul.Object.Converters 1.0.12

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

// Install VersaTul.Object.Converters as a Cake Tool
#tool nuget:?package=VersaTul.Object.Converters&version=1.0.12                

VersaTul Object Converters

VersaTul Object Converters is a project that provides the ability to convert objects into key/value pairs dictionary stores. For example, you can use converters to convert instances of classes into a dictionary representation of the data from the class. This package works with the Collection streamers package.

Features

  • IFlattener: An interface that describes the functionality needed to successfully convert from a multi-dimensional object to a one-dimensional key/value pair dictionary with flattened keys.
  • IObjectProcessor: An interface that represents functionality that can convert an object into a dictionary of string keys and object values.
  • IPropertyProcessor: An interface that describes the functionality needed to successfully process the properties of object instances.
  • ObjectProcessor: A concrete implementation of IObjectProcessor.
  • PropertyProcessor: A concrete implementation of IPropertyProcessor.

Usage

To use VersaTul Object Converters, you need to install the package and import the relevant classes. Then, you can create instances of ObjectProcessor and PropertyProcessor and use their methods to convert objects into dictionaries. For example:

using VersaTul.ObjectConverters;

// Create an object to convert
var person = new Person
{
    Name = "John",
    Age = 25,
    Address = new Address
    {
        Street = "123 Main St",
        City = "New York",
        Zip = "10001"
    }
};

// Create an instance of ObjectProcessor
var objectProcessor = new ObjectProcessor();

// Convert the object into a dictionary
var dictionary = objectProcessor.ToDictionary(person);

// Print the dictionary
foreach (var pair in dictionary)
{
    Console.WriteLine($"{pair.Key}: {pair.Value}");
}

The output of this code would be:

Name: John
Age: 25
Address.Street: 123 Main St
Address.City: New York
Address.Zip: 10001

You can also use the IFlattener interface to convert a dictionary into a string or another dictionary with flattened keys. For example:

using VersaTul.ObjectConverters;

// Create a dictionary to convert
var dictionary = new Dictionary<string, object>
{
    {"Name", "John"},
    {"Age", 25},
    {"Address", new Dictionary<string, object>
        {
            {"Street", "123 Main St"},
            {"City", "New York"},
            {"Zip", "10001"}
        }
    }
};

// Create an instance of Flattener
var flattener = new Flattener();

// Convert the dictionary into a string
var string = flattener.AsString(dictionary);

// Print the string
Console.WriteLine(string);

The output of this code would be:

Name=John;Age=25;Address.Street=123 Main St;Address.City=New York;Address.Zip=10001

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on VersaTul.Object.Converters:

Package Downloads
VersaTul.Extensions

The VersaTul Extensions project provides a variety of methods for manipulating arrays, performing conversions and other common functionalities.

VersaTul.Collection.Streamers

The VersaTul Collection Streamers provides functionality that enables developers to quickly convert a collection of objects in memory into a data-reader that can be used for Bulk inserting data into a SQL Database, or be used to generate flat files. Developers can use the streamers to: 1. Convert a Collection to a Data-Reader. 2. Convert from a Data-Reader to other file formats such as CSV, TAB or Json. 3. Compress converted data into Zip files. 4. Transport the converted data via e-mail. The Streamers project also works with Display Attributes which is used to manipulate the properties on the objects in the collection such as formatting the data or renaming the property with a desired display name.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.12 890 2/26/2024
1.0.11 317 2/1/2024
1.0.10 693 1/15/2024
1.0.9 544 1/11/2024
1.0.8 964 7/22/2023