Knoxgon.TurboDyno
5.1.0.2
See the version list below for details.
dotnet add package Knoxgon.TurboDyno --version 5.1.0.2
NuGet\Install-Package Knoxgon.TurboDyno -Version 5.1.0.2
<PackageReference Include="Knoxgon.TurboDyno" Version="5.1.0.2" />
paket add Knoxgon.TurboDyno --version 5.1.0.2
#r "nuget: Knoxgon.TurboDyno, 5.1.0.2"
// Install Knoxgon.TurboDyno as a Cake Addin #addin nuget:?package=Knoxgon.TurboDyno&version=5.1.0.2 // Install Knoxgon.TurboDyno as a Cake Tool #tool nuget:?package=Knoxgon.TurboDyno&version=5.1.0.2
TurboDyno
TurboDyno, turbo, clax, dynamic property maker and mapper using Reflection
Authors
Volkan Güven ® KnoxGoN - 2022
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 (ca 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!
Requirements
Supported frameworks
.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.1.0.2
Version History
5.1.0.2
Bugfix: Erroneous value returned from from the passed token on DynoPropertyValues
5.1.0.1
Added support for .NET 5.0, .Net Framework 4.8 and 4.7.2
5.1.0
Stabilized and fully tested. It is now in Beta-phase.
5.0.0 Deprecated
4.4.5.5 Deprecated
4.4.5.4 Deprecated
4.4.5.3 Deprecated
4.4.5 Deprecated
4.4.5 Deprecated
4.4.1.2 Deprecated
4.3.5.3 Deprecated
4.3.5.2 Deprecated
4.3.0 Deprecated
4.2.0 Deprecated
4.1.5 Deprecated
4.1.10 Deprecated
2.2.3.25 Deprecated
2.1.5.10 Deprecated
1.0.0 Deprecated
Supported property types
- bool
- decimal
- float
- double
- long
- ulong
- int
- uint
- short
- ushort
- DateTime
- DateTime?
- byte
- nint
- nuint
- sbyte
- char
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.
- 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 dynamicPersonType = 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.
//Kind of like -> var list = new List<int>();
List<object> dynamicPersonObjectList = dynamicPersonType.NewList();
//Returns the created property names.
var dynamicPersonPropertyNames = Clax.GetPropertyNames();
}
- 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 dynamicPersonType = 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 = dynamicPersonType.NewList();
//Returns the created property names.
var dynamicPersonPropertyNames = Clax.GetPropertyNames();
}
Clax Function API
Name | Parameters | Returns | Description |
---|---|---|---|
Create | IEnumerable<PropertyInfo> properties<br/>string className<br/> string optionalNamespace<br/>params string[] libraries | 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[] libraries | 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 | Converts created type object to a list | Gets the list of object properties | ||
DynoPropertyValues | List<object> | IEnumerable<object> | Returns a list of values of each property in a dyno list | ||
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 | object | object | Creates and returns a dyno instance of your object. Type is auto fetched from the object. | ||
New | Type | object | Creates and returns a dyno instance of your type. | ||
NewList | object | List<object> | Creates a dyno instance list of your object. Type is auto fetched from the object. | ||
NewList | Type | List<object> | Creates a dyno instance list of your type. |
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 | Versions 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. |
-
.NETFramework 4.7.2
- Microsoft.CodeAnalysis.Common (>= 4.1.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.1.0)
- System.Linq (>= 4.3.0)
-
.NETFramework 4.8
- Microsoft.CodeAnalysis.Common (>= 4.1.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.1.0)
- System.Linq (>= 4.3.0)
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.Common (>= 4.1.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.1.0)
- System.Linq (>= 4.3.0)
-
.NETStandard 2.1
- Microsoft.CodeAnalysis.Common (>= 4.1.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.1.0)
- System.Linq (>= 4.3.0)
-
net5.0
- Microsoft.CodeAnalysis.Common (>= 4.1.0)
- Microsoft.CodeAnalysis.CSharp (>= 4.1.0)
- System.Linq (>= 4.3.0)
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,300 | 3/15/2022 | |
5.1.0.3 | 2,486 | 3/13/2022 | |
5.1.0.2 | 1,214 | 3/13/2022 | |
5.1.0.1 | 1,207 | 3/13/2022 | |
5.1.0 | 1,240 | 3/13/2022 | |
5.0.0 | 1,171 | 3/13/2022 | |
4.4.5.5 | 1,214 | 3/11/2022 | |
4.4.5.4 | 1,210 | 3/11/2022 | |
4.4.5.3 | 1,233 | 3/11/2022 | |
4.4.5 | 1,223 | 3/11/2022 | |
4.4.1.2 | 1,220 | 3/11/2022 | |
4.3.5.3 | 1,242 | 3/11/2022 | |
4.3.5.2 | 1,215 | 3/11/2022 | |
4.3.0 | 1,181 | 3/11/2022 | |
4.2.0 | 1,203 | 3/10/2022 | |
4.1.5 | 1,275 | 3/10/2022 | |
4.1.0 | 1,169 | 3/10/2022 | |
2.2.3.25 | 1,316 | 3/9/2022 | |
2.1.5.10 | 1,252 | 3/9/2022 | |
1.0.0 | 1,180 | 3/9/2022 |
Bugfix: Erroneous value returned from from the passed token on DynoPropertyValues