TypeSupport 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package TypeSupport --version 1.0.0
NuGet\Install-Package TypeSupport -Version 1.0.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="TypeSupport" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TypeSupport --version 1.0.0
#r "nuget: TypeSupport, 1.0.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 TypeSupport as a Cake Addin
#addin nuget:?package=TypeSupport&version=1.0.0

// Install TypeSupport as a Cake Tool
#tool nuget:?package=TypeSupport&version=1.0.0

TypeSupport

A CSharp library that makes it easier to work with Types dynamically by providing extensions and tools that makes your life easier. Additionally, it includes a flexible Object factory for creating and initializing all kinds of types.

Description

The best way to understand what TypeSupport can do is to see it in action! It is used as the foundation for many other packages.

Installation

Install TypeSupport from the Package Manager Console:

PM> Install-Package TypeSupport

Usage

Type Support

Getting started - create a TypeSupport from a type

using TypeSupport;

var type = typeof(MyObject);
var typeSupport = new TypeSupport(type);

or do it using the extensions (we will use this syntax going forward):

using TypeSupport;

var type = typeof(MyObject);
var typeSupport = type.TypeSupport();

get information about an array:

var type = typeof(int[]);
var typeSupport = type.TypeSupport();

var isArray = typeSupport.IsArray; // true
var elementType = typeSupport.ElementType; // int

get information about a Dictionary:

var type = typeof(Dictionary<int, string>);
var typeSupport = type.TypeSupport();

var isArray = typeSupport.IsDictionary; // true
var elementTypes = typeSupport.GenericArgumentTypes; // System.Int32, System.String

get info about an interface:

var type = typeof(IVehicle);
var typeSupport = type.TypeSupport();

var isArray = typeSupport.IsInterface; // true
var classesThatImplementICustomInterface = typeSupport.KnownConcreteTypes;
// [] = Car, Truck, Van, Motorcycle

get info about a class:

[Description("A car object")]
public class Car : IVehicle
{
  public string Name { get; set; }
  public Car() { }
}
var type = typeof(Car);
var typeSupport = type.TypeSupport();

var isArray = typeSupport.HasEmptyConstructor; // true
var attributes = typeSupport.Attributes;
// [] = DescriptionAttribute

working with enums:

public enum Colors : byte
{
  Red = 1,
  Green = 2,
  Blue = 3
}
var type = typeof(Colors);
var typeSupport = type.TypeSupport();

var isEnum = typeSupport.IsEnum; // true
var enumValues = typeSupport.EnumValues;
// [] = <1, Red>, <2, Green>, <3, blue>
var enumType = typeSupport.EnumType; // System.Byte

working with Tuples:

var tupleType = typeof(Tuple<int, string, double>);
var valueTupleType = typeof((IVehicle, string));
var tupleTypeSupport = type.TypeSupport();
var valueTupleTypeSupport = valueTupleType.TypeSupport();

var isTuple = tupleTypeSupport.IsTuple; // true
var isValueTuple = valueTupleTypeSupport.IsValueTuple; // true
var tupleGenericArguments = tupleTypeSupport.GenericArgumentTypes; // System.Int32, System.String, System.Double
var valueTupleGenericArguments = valueTupleTypeSupport.GenericArgumentTypes; // IVehicle, System.String
// there's lots more you can do, such as getting the value from a Tuple instance:

var car = new Car();
var description = "My cool car";
var myTuple = (car, description);
var items = myTuple.GetValueTupleItemObjects();
// [] = Car, "My cool car"

Object factory

Create new objects of any type:

var factory = new ObjectFactory();
var listInstance = factory.CreateEmptyObject<IList<int>>(); // List<int>() 0 elements
var dictionaryInstance = factory.CreateEmptyObject<IDictionary<int, string>>(); // Dictionary<int, string>() 0 elements
var emptyByteArray = factory.CreateEmptyObject<byte[]>(); // byte[0] empty byte array
var byteArray = factory.CreateEmptyObject<byte[]>(length: 64); // byte[64]
var tupleInstance = factory.CreateEmptyObject<(int, string)>(); // tupleInstance.Item1 = 0, tupleInstance.item2 = null
var myComplexObject = factory.CreateEmptyObject<MyComplexObject>();

Create objects without parameterless constructors:

public class CustomObject
{
  public int Id { get; }
  public CustomObject(int id)
  {
    Id = id;
  }
}
var factory = new ObjectFactory();
var myObj = factory.CreateEmptyObject<CustomObject>(); // CustomObject
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.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (15)

Showing the top 5 NuGet packages that depend on TypeSupport:

Package Downloads
Blazor-State

A Blazor state management library by TimeWarp

AnySerializer

Serialize and deserialize any object without decoration/attributes.

Core-State

A fork of blazor-state. Core State is a MediatR pipeline for Blazor, Xamarin, UWP, WPF state management

Binner.Model.Common

Binner common model library

Binner.StorageProvider.MySql

MySql storage provider for Binner

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on TypeSupport:

Repository Stars
TimeWarpEngineering/blazor-state
A Blazor State management library by TimeWarp.
replaysMike/Binner
Open source parts inventory system for makers, electronics hobby, and professional engineers
replaysMike/AnyDiff
A CSharp (C#) diff library that allows you to diff two objects and get a list of the differences back.
Version Downloads Last updated
1.2.0 43,701 3/14/2023
1.1.12 150,615 9/15/2021
1.1.11 443 8/10/2021
1.1.10 757 7/29/2021
1.1.8 442 7/28/2021
1.1.7 449 7/28/2021
1.1.4 107,529 7/9/2020
1.1.3 4,927 6/9/2020
1.1.0 494 6/9/2020
1.0.108 33,349 4/18/2020
1.0.107 478 4/18/2020
1.0.106 703 4/16/2020
1.0.104 488 4/16/2020
1.0.103 482 4/16/2020
1.0.102 7,954 4/13/2020
1.0.100 6,876 1/8/2020
1.0.99 538 1/7/2020
1.0.98 542 1/7/2020
1.0.97 3,219 12/2/2019
1.0.92 13,220 6/30/2019
1.0.90 75,956 5/22/2019
1.0.89 966 5/22/2019
1.0.88 808 5/22/2019
1.0.86 620 5/22/2019
1.0.85 608 5/22/2019
1.0.79 85,193 5/16/2019
1.0.78 592 5/16/2019
1.0.77 629 5/15/2019
1.0.76 606 5/15/2019
1.0.73 686 5/9/2019
1.0.68 608 5/1/2019
1.0.66 2,911 4/20/2019
1.0.62 638 4/20/2019
1.0.61 629 4/20/2019
1.0.58 628 4/17/2019
1.0.54 644 4/15/2019
1.0.51 966 4/14/2019
1.0.46 45,387 12/20/2018
1.0.45 2,560 12/20/2018
1.0.44 685 12/19/2018
1.0.43 693 12/19/2018
1.0.42 712 12/19/2018
1.0.34 687 12/19/2018
1.0.26 1,027 12/12/2018
1.0.15 793 12/5/2018
1.0.14 743 12/5/2018
1.0.12 13,100 12/4/2018
1.0.10 42,624 12/2/2018
1.0.8 1,340 12/2/2018
1.0.7 1,258 11/30/2018
1.0.6 1,423 11/29/2018
1.0.5 1,456 11/29/2018
1.0.4 1,555 11/28/2018
1.0.3 1,015 11/22/2018
1.0.2 721 11/22/2018
1.0.1 716 11/22/2018
1.0.0 776 11/21/2018

TypeSupport provides tools to give you more information about .Net types and factories for working with objects, collections, enums and more.