Knoxgon.TurboDyno 5.2.0

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

// Install Knoxgon.TurboDyno as a Cake Tool
#tool nuget:?package=Knoxgon.TurboDyno&version=5.2.0

TurboDyno

NuGet Version Issues

TurboDyno, turbo, clax, dynamic property maker and mapper using Reflection

Authors

Wolf Guven ® KnoxGoN - 2022

@Linkedin @GitHub

Introduction

This project is created to help users refer the documentation of TurboDyno..

API, methods declaration, and its signatures are described with details.

Motive

When one needs to create a class with dynamic properties, it shouldn't be hard to do it. Unfortunately, there isn't an easy way to pull it off.

I've created this library as a hobby project to help with my work duties. With this library, you could create a whole new class by either passing arbitrary number of properties or passing a huge class with properties, map it, create a new instance of it and even keep the property record of the created class at runtime.

Since this project is created in a relatively short time (approximately 6 hours), I haven't had time to create support for nested object properties and custom object types. But don't worry! It's on the way!

All types are supported with version >= 5.2.0.0. Read release notes under Version History

Requirements

Supported frameworks

@Windows

  • .NET 5.0

  • .NET Standard 2.0

  • .NET Framework 4.8

  • .NET Framework 4.7.2

  • ...More on the way

Installation

Package manager installation

Install-Package Knoxgon.TurboDyno -Version 5.2.0.0

Version History

  • 5.2.0.0

      Huge improvement. Complex data types and structured can now be created with this version.
      Affected APIs:
      	'Create': 
      	1. Improvised Create function. Removed 'library' from the parameter list.
      	2. Added parameter 'assemblies' to allow user to add assemblies upon need.
      	3. All types for properties are now supported. Including nullable types.
     Beta-phase is complete.
    
  • 5.1.0.3

      Feature: Added support to directly get dyno type attributes via GetDynoProperties
    
  • 5.1.0.2

      Added support for .NET 5.0, .Net Framework 4.8 and 4.7.2.
      Bugfix: Erroneous value returned from from the passed token on 'DynoPropertyValues'.
      version 5.1.0.1 is deprecated due to the critical bugfix.
    
  • 5.1.0.1 Deprecated

  • 5.1.0

      Stabilized and fully tested. It is now in Beta-phase.
    
  • 1.0.0 <> 5.0.0 Deprecated

Supported types

All types are supported with version >= 5.2.0.0

Nullable of primitive types are not fully tested. They may be unstable. They will be released after detailed test executions. DateTime and nullable of its type is however fully supported.

Example usage

In the following list, you'll see different usages of Clax.

Clax is the TurboDyno facility class to be able to use necessary functions. Core methods reside within Clax.

  1. The first example lets you map, copy and return a dynamic type of PersonRecord. It solely copies properties from the provided generic type.
using System;
using Knoxgon.TurboDyno;

public class PersonRecord
{
    public long Id { get; set; }
    public string Name { get; set; }
    public DateTime BirthDate { get; set; }
    public bool Status { get; set; }
}

void static main()
{
    //Creates new class from PersonRecord's properties.
    Type type = Clax.Create<PersonRecord>(className: "MyDynamicPersonClass");

    //Gets the list of property info for each created dynamic property
    IEnumerable<Reflection.PropertyInfo> dynamicPersonProperties = dynamicPersonObject.GetDynoProperties();
    
    //Creates and returns a newly created list of the object type.
    List<object> dynamicPersonObjectList = type.NewList();
    
    //Returns the created property names.
    var dynamicPersonPropertyNames = Clax.GetPropertyNames();
}

  1. Let's create an arbitrary number of properties by passing a property list this time.
void static main()
{
    //For the simplest example, let's pass 2 runtime properties
    //NOTE that any property from any class can easily be mapped using the same method.
    
    //Properties: string: RepoId, bool: Active
    var listOfProps = ...;
    
    Type type = Clax.Create(listOfProps, className: "MyDynamicPersonClass");

    //Gets the list of property info for each created dynamic property
    //You'll get RepoId and Active
    IEnumerable<Reflection.PropertyInfo> dynamicPersonProperties = dynamicPersonObject.GetDynoProperties();
    
    //A list instance of the new generated class type with RepoId and Active as members.
    List<object> dynamicPersonObjectList = type.NewList();
    
    //Returns the created property names.
    List<string> dynamicPersonPropertyNames = Clax.GetPropertyNames();
}

Clax Function API

Name Parameters Returns Description
Create IEnumerable<PropertyInfo> properties<br/>string className<br/> string optionalNamespace<br/>params string[] assemblies Type Builds and creates a dynamic class with passed properties. Properties can be created, mapped and passed by the user
Create<T> string className<br/>string optionalNamespace<br/>params string[] assemblies Type Builds and creates a dynamic class from the provided generic class T. Properties are assigned with getter and setter.
GetPropertyNames List<string> A list of property names of the original passed type.

DynoExtensions Function API

Name Extension Parameters Returns Description
ToDynoList<T> T List<T> Converts created type object to a list
GetDynoProperties<T> Type IEnumerable<object> Gets the list of object properties
DynoPropertyValues<T> List<T> IEnumerable<object> Returns a list of values of each property in a generic dyno list
DynoPropertyValues<object> List<object> string propertyName,<br/> string token,<br/>DynoFilterAction action IEnumerable<object> Returns a filtered list of values of each property in a dyno list with a single name predicate. <br/>This specific method allows to keep or remove the provided string token from the start of the value from the targeted property
DynoPropertyNames List<object> IEnumerable<string> Returns a list of property names for each object in the passed dyno list
New T object Creates and returns a dyno object. Type is auto fetched from the object.
NewList T List<object> Creates a dyno list. Type is auto fetched from the object.

DynoFilterAction enum API

The following enums are currently only needed to be used on DynoPropertyValues<object>

Name Value Description
NO_ACTION 0 No modification action is performedon the property values upon calling DynoPropertyValues extension method
KEEP 1 Keeping the provided token on the pointed propertyName's value
REMOVE 2 Removing the provided token on the pointed propertyName's value

Maintainers

I'm currently the only person to maintain the library.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  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
5.2.0 1,261 3/15/2022
5.1.0.3 2,188 3/13/2022
5.1.0.2 1,182 3/13/2022
5.1.0.1 1,177 3/13/2022
5.1.0 1,211 3/13/2022
5.0.0 1,141 3/13/2022
4.4.5.5 1,182 3/11/2022
4.4.5.4 1,180 3/11/2022
4.4.5.3 1,203 3/11/2022
4.4.5 1,180 3/11/2022
4.4.1.2 1,190 3/11/2022
4.3.5.3 1,211 3/11/2022
4.3.5.2 1,188 3/11/2022
4.3.0 1,156 3/11/2022
4.2.0 1,160 3/10/2022
4.1.5 1,229 3/10/2022
4.1.0 1,138 3/10/2022
2.2.3.25 1,254 3/9/2022
2.1.5.10 1,221 3/9/2022
1.0.0 1,148 3/9/2022

Huge improvement. Complex data types and structured can now be created with this version.
 Affected APIs:
  'Create':
  1. Improvised Create function. Removed 'library' from the parameter list.
  2. Added parameter 'assemblies' to allow user to add assemblies upon need.
  3. All types for properties are now supported. Including nullable types.
Beta-phase is complete.