TypeCache 9.1.2

dotnet add package TypeCache --version 9.1.2
                    
NuGet\Install-Package TypeCache -Version 9.1.2
                    
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="TypeCache" Version="9.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TypeCache" Version="9.1.2" />
                    
Directory.Packages.props
<PackageReference Include="TypeCache" />
                    
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 TypeCache --version 9.1.2
                    
#r "nuget: TypeCache, 9.1.2"
                    
#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 TypeCache@9.1.2
                    
#: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=TypeCache&version=9.1.2
                    
Install as a Cake Addin
#tool nuget:?package=TypeCache&version=9.1.2
                    
Install as a Cake Tool

TypeCache {$}

sam987883@gmail.com

Source Code

Request Features (or report a bug) (if any)


TypeCache.Extensions - Faster Reflection

using TypeCache.Extensions;

// Create an instance of Senator using the default constructor
var intance = typeof(Senator).Create();

// Create an instance of Customer using a matching constructor
var intance = typeof(Senator).Create(["Bob Dole", 98]); // Passing an array of values
var intance = typeof(Senator).Create(("Bob Dole", 98)); // Passing a tuple of values

// Find the matching ConstructorInfo object based on argument values
var comstructorInfo = typeof(Senator).FindConstructor(["Bob Dole", 98]) // Passing an array of values
var comstructorInfo = typeof(Senator).FindConstructor(("Bob Dole", 98)) // Passing a tuple of values

// Find a matching MethodInfo object based on argument values
var methodInfo = typeof(Senator).FindMethod("RunForPresident", [typeof(int), typeof(bool)]); // Find method by argument types
var methodInfo = typeof(Senator).FindMethod("RunForPresident", [1996, true]); // Passing an array of values
var methodInfo = typeof(Senator).FindMethod("RunForPresident", (1996, true)); // Passing a tuple of values

// Get a field value
var fieldValue = typeof(Senator).GetFieldValue(instance, "_Bills");

var fieldInfo = typeof(Senator).GetFieldInfo(instance, "_Bills");
var fieldValue = fieldInfo.GetValueEx("_Bills");

// Set a field value
var fieldValue = typeof(Senator).SetFieldValue(instance, "_Bills", 47);

var fieldInfo = typeof(Senator).GetFieldInfo(instance, "_Bills");
var fieldValue = fieldInfo.SetValueEx("_Bills");

// Get a property value
var propertyValue = typeof(Senator).GetPropertyValue(instance, "DoleWhip");

var propertyInfo = typeof(Senator).GetPropertyInfo(instance, "DoleWhip");
var propertyValue = propertyInfo.GetValueEx("DoleWhip");

// Set a property value
var propertyValue = typeof(Senator).SetPropertyValue(instance, "DoleWhip", Fruits.Pineapple);

var propertyInfo = typeof(Senator).GetPropertyInfo(instance, "DoleWhip");
var propertyValue = propertyInfo.SetValueEx("DoleWhip", Fruits.Pineapple);

// Invoke a method
typeof(Senator).InvokeAction("StopHillaryCare", ["Oh noes", Action.Veto, false]); // Passing an array of values
typeof(Senator).InvokeAction("StopHillaryCare", ("Oh noes", Action.Veto, false)); // Passing a tuple of values

var state = typeof(Senator).InvokeFunc("GetState");

TypeCache.Extensions - Better Object Mapping

using TypeCache.Extensions;

var dictionary = new Dictionary<string, object>(2)
{
	{ "Name", "Bob Dole" },
	{ "Age", 98 }
};
var bobDole1 = new Representative();
var bobDole2 = new Senator();
var bobDole3 = null as President;

dictionary.MapTo(bobDole1); // Automatically maps dictionary entries to properties
bobDole1.MapTo(bobDole2); // Automatically maps model properties with same names

// To further customize mappings, use MapAttribute and MapIgnoreAttribute

TypeCache.Mediation - Mediator that supports named rules

using TypeCache.Mediation;

IMediator mediator; // Injected

var bobDole1 = new Representative(); // Implements IRequest<Senator>
Senator bobDole2 = mediator.Map(bobDole1); // Implements IRequest<President>

mediator.Execute("Presidential Campaign", bobDole2);

President? bobDole3 = mediator.Map(nameof(President), bobDole2); // Map using named Rule

bobDole3.AssertNotNull(); // Unhandled exception

TypeCache.Data - Simple Robust Database CRUD Access


TypeCache.Extensions - Helpful Extensions

using TypeCache.Extensions;

// Assertions
instance.AssertNotNull(); // Throws ArgumentNullException if instance is null

text.AssertNotBlank(); // Throws ArgumentException if text is null, empty or whitespaces

success.AssertTrue(); // Throws ArgumentException is success is not true (false or null)

// Action/Func Retry on fail
Action runForPresident;

runForPresident.Retry([TimeSpan.FromYears(4)]);

var timeSpan = runForPresident.Timed(); // Involes the Action and returns how long it took to run

// Comparable Extensions
IComparable<Senator> gingrich, bobDole;
var success = bobDole.CompareTo(gingrich) > 0; // Cryptic
success = bobDole.GreaterThan(gingrich); // More readable

// DateTime extensions
var bobDoleDOB = new DateOnly(1923, 7, 22);

// The following does not throw an exception as Between is inclusive of its endpoints.
bobDoleDOB.Between(new DateOnly(1923, 7, 22), new DateOnly(2021, 12, 5)).AssertTrue();

// The following throws an exception as InBetween is exclusive of its endpoints.
bobDoleDOB.InBetween(new DateOnly(1923, 7, 22), new DateOnly(2021, 12, 5)).AssertTrue();

var dateOnly = DateTime.UtcNow.ToDateOnly();
var dateTimeOffset = DateTime.UtcNow.ToDateTimeOffset();
var dateForUI = DateTime.UtcNow.ToISO8601();

var utcDateTime = DateTIme.Now.ToTimeZone(TimeZoneInfo.Utc)
utcDateTime = DateTIme.Now.ToUTC();

// JSON
JsonNode json;
// Access JSON nodes using JSON Path expression
var nodes = json.GetNodes("$.Politicians.Senators[1].*");
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
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 TypeCache:

Package Downloads
TypeCache.GraphQL

An easier way to add endpoints to GraphQL: Attribute based GraphQL type generation. Simplified GraphQL DataLoader support. Automatic generation of SQL related endpoints.

TypeCache.Web

Web API access to SQL database data operations: allows the front-end to decide how to retrieve and manipulate data.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.1.2 109 4/25/2025
9.1.1 179 4/23/2025
9.1.0 107 2/23/2025
9.0.2 123 12/15/2024
9.0.1 128 12/6/2024
9.0.0 132 11/26/2024
8.5.1 172 4/24/2025
8.5.0 114 2/24/2025
8.4.3 129 12/15/2024
8.4.2 108 12/6/2024
8.4.1 154 11/26/2024
8.4.0 149 10/28/2024
8.3.1 195 6/21/2024
8.3.0 149 4/17/2024
8.2.1 273 3/20/2024
8.2.0 270 3/19/2024
8.1.3 317 3/8/2024
8.1.2 540 1/31/2024
8.1.1 592 1/31/2024
8.1.0 542 1/31/2024
8.0.1 798 12/20/2023
8.0.0 1,000 12/11/2023
7.5.0 247 3/21/2024
7.4.1 910 11/12/2023
7.4.0 1,070 9/10/2023
7.3.14 1,153 8/13/2023
7.3.13 1,182 7/30/2023
7.3.12 1,197 7/17/2023
7.3.11 1,243 6/14/2023
7.3.10 1,341 3/19/2023
7.3.9 1,284 3/10/2023
7.3.8 1,352 3/10/2023
7.3.6 1,350 1/24/2023
7.3.5 1,387 1/22/2023
7.3.4 1,354 1/18/2023
7.3.3 1,348 1/17/2023
7.3.2 1,378 1/15/2023
7.3.1 1,402 1/11/2023
7.2.6 1,381 12/26/2022
7.2.5 1,437 12/26/2022
7.2.3 1,400 12/25/2022
7.2.2 1,530 12/25/2022
7.2.1 1,370 12/14/2022
7.2.0 1,478 12/14/2022
7.1.3 1,413 12/4/2022
7.1.2 1,401 11/27/2022
7.1.1 1,436 11/23/2022
7.1.0 1,427 11/21/2022
7.0.0 1,396 11/17/2022
6.3.2 1,311 3/19/2023
6.3.1 1,303 3/10/2023
6.3.0 1,369 2/1/2023
6.2.0 1,741 8/17/2022
6.1.3 1,670 4/20/2022
6.1.2 1,764 4/18/2022
6.1.1 1,749 3/27/2022
6.1.0 1,791 3/14/2022
6.0.9 1,633 3/7/2022
6.0.8 1,754 3/7/2022
6.0.7 1,370 1/8/2022
6.0.6 1,539 1/6/2022
6.0.5 1,417 1/4/2022
6.0.4 1,366 1/2/2022
6.0.3 1,530 1/1/2022
6.0.2 1,537 12/21/2021
6.0.1 2,531 11/28/2021
6.0.0 1,560 11/15/2021
1.0.67 1,582 10/24/2021
1.0.66 1,859 10/3/2021
1.0.65 1,710 9/11/2021
1.0.64 1,502 9/10/2021
1.0.63 1,569 9/4/2021
1.0.62 1,674 8/28/2021
1.0.61 1,734 8/15/2021
1.0.60 1,599 8/8/2021
1.0.59 1,462 8/2/2021
1.0.58 1,450 8/2/2021
1.0.57 1,611 8/1/2021
1.0.56 1,589 7/19/2021
1.0.55 1,438 7/18/2021
1.0.54 1,560 7/18/2021
1.0.53 1,508 7/18/2021
1.0.52 1,427 7/14/2021
1.0.51 1,478 7/11/2021
1.0.50 1,601 7/11/2021
1.0.49 1,518 7/2/2021
1.0.48 1,482 6/30/2021
1.0.47 1,637 6/30/2021
1.0.46 1,642 6/18/2021
1.0.45 1,488 6/12/2021
1.0.44 1,586 6/11/2021
1.0.43 1,649 6/10/2021
1.0.42 1,632 6/6/2021
1.0.41 1,568 6/5/2021
1.0.40 1,564 6/1/2021
1.0.39 1,606 5/31/2021
1.0.38 1,668 5/30/2021
1.0.37 1,568 5/30/2021
1.0.36 1,682 4/5/2021
1.0.35 1,667 3/28/2021
1.0.34 1,675 3/22/2021
1.0.33 1,535 3/18/2021
1.0.32 1,668 3/18/2021
1.0.31 1,557 3/17/2021
1.0.30 1,729 3/17/2021
1.0.29 1,605 3/9/2021
1.0.28 1,752 3/7/2021
1.0.27 1,790 3/1/2021
1.0.26 1,593 2/28/2021
1.0.25 1,566 2/26/2021
1.0.24 1,769 2/25/2021
1.0.23 1,692 2/24/2021
1.0.22 1,551 2/21/2021
1.0.21 1,637 2/20/2021
1.0.20 1,691 2/19/2021
1.0.19 1,563 2/2/2021
1.0.18 1,719 1/29/2021
1.0.17 1,781 1/28/2021
1.0.16 1,741 1/23/2021
1.0.15 1,912 12/26/2020
1.0.14 2,308 12/20/2020
1.0.13 2,174 12/20/2020
1.0.12 1,927 8/20/2020
1.0.11 1,965 8/7/2020
1.0.10 1,992 7/28/2020
1.0.9 2,061 7/28/2020
1.0.8 2,066 7/25/2020
1.0.7 2,039 7/21/2020
1.0.6 2,089 7/5/2020
1.0.5 2,108 7/5/2020
1.0.4 2,024 7/4/2020
1.0.3 2,054 7/3/2020
1.0.2 2,045 7/3/2020
1.0.1 2,076 7/2/2020
1.0.0 2,028 6/17/2020