TypeCache 10.1.0

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

TypeCache {$}

sam987883@gmail.com

Source Code

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


TypeCache.Reflection - Faster Reflection

using TypeCache.Reflection;

// 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 = Type<Senator>.Create(["Bob Dole", 98]); // Passing an array of values
var intance = typeof(Senator).Create(["Bob Dole", 98]); // Passing an array of values
var intance = Type<Senator>.Create(("Bob Dole", 98)); // Passing a tuple of strongly-typed values
var intance = typeof(Senator).Create(("Bob Dole", 98)); // Passing a tuple of strongly-typed values

// Find the matching ConstructorInfo object based on argument values
var comstructorEntity = Type<Senator>.Constructors.Find(["Bob Dole", 98]) // Passing an array of values
var comstructorEntity = typeof(Senator).Constructors.Find(["Bob Dole", 98]) // Passing an array of values
var comstructorEntity = Type<Senator>.Constructors.Find(("Bob Dole", 98)) // Passing a tuple of strongly-typed values
var comstructorEntity = typeof(Senator).Constructors.Find(("Bob Dole", 98)) // Passing a tuple of strongly-typed values

// Find a matching MethodInfo object based on argument values
var methodEntity = Type<Senator>.Methods["RunForPresident"].Find([typeof(int), typeof(bool)]); // Find method by argument types
var methodEntity = typeof(Senator).Methods["RunForPresident"].Find([typeof(int), typeof(bool)]); // Find method by argument types
var methodEntity = Type<Senator>.Methods["RunForPresident"].Find([1996, true]); // Passing an array of values
var methodEntity = typeof(Senator).Methods["RunForPresident"].Find([1996, true]); // Passing an array of values
var methodEntity = Type<Senator>.Methods["RunForPresident"].Find((1996, true)); // Passing a tuple of strongly-typed values
var methodEntity = typeof(Senator).Methods["RunForPresident"].Find((1996, true)); // Passing a tuple of strongly-typed values

// Get a field value
var fieldValue = instance & "_Bills";
var fieldValue = Type<Senator>.Fields["_Bills"].GetValue(instance);
var fieldValue = typeof(Senator).Fields["_Bills"].GetValue(instance);

// Set a field value
var success = instance & ("_Bills", 47);
Type<Senator>.Fields["_Bills"].SetValue(instance, 47);
typeof(Senator).Fields["_Bills"].SetValue(instance, 47);

var fieldEntity = Type<Senator>.Fields["_Bills"];
var fieldEntity = typeof(Senator).Fields["_Bills"];
fieldEntity.SetValue(instance, 47);

// Get a property value
var propertyValue = instance & "DoleWhip";
var propertyValue = Type<Senator>.Properties["DoleWhip"].GetValue(instance);
var propertyValue = typeof(Senator).Properties["DoleWhip"].GetValue(instance);

var propertyEntity = Type<Senator>.Properties["DoleWhip"];
var propertyEntity = typeof(Senator).Properties["DoleWhip"];
var propertyValue = propertyEntity.GetValue(instance);

// Set a property value
var success = instance & ("DoleWhip", Fruits.Pineapple);
Type<Senator>.Properties["DoleWhip"].SetValue(instance, Fruits.Pineapple);
typeof(Senator).Properties["DoleWhip"].SetValue(instance, Fruits.Pineapple);

var propertyEntity = Type<Senator>.Properties["DoleWhip"];
var propertyEntity = typeof(Senator).Properties["DoleWhip"];
propertyEntity.SetValueEx("DoleWhip", Fruits.Pineapple);

// Invoke a method passing a tuple of strongly-typed values
intance | "StopHillaryCare" & ("Oh noes", Action.Veto, false);
intance | "GenericMethod1" | typeof(string) & ("Oh noes", false);
intance | "GenericMethod2" | [typeof(string), typeof(int)] & ("Oh noes", 999, true, false);
var result = typeof(Senator) | "StaticMethod1" & ("Agr1", Action.Veto, false);

// Equivalent traditional calls
Type<Senator>.Methods["StopHillaryCare"].Invoke(instance, ("Oh noes", Action.Veto, false));
typeof(Senator).Methods["StopHillaryCare"].Invoke(instance, ("Oh noes", Action.Veto, false));

// Invoke a method passing an array of object typed values
Type<Senator>.Methods["StopHillaryCare"].Invoke(instance, ["Oh noes", Action.Veto, false]); // Passing an array of values
typeof(Senator).Methods["StopHillaryCare"].Invoke(instance, ["Oh noes", Action.Veto, false]); // Passing an array of values

var state = instance | "GetState" & ValueTuple.Create(); // Use for no arguments
var state = Type<Senator>.Methods["GetState"].Invoke(instance);
var state = typeof(Senator).Methods()["GetState"].Invoke(instance);

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.MapProperties(bobDole1); // Automatically maps dictionary entries to properties
dictionary.MapFields(bobDole2); // Automatically maps dictionary entries to fields

// To further customize mappings, use MapAttribute and MapIgnoreAttribute

TypeCache.Mediation - Mediator that supports named rules

using TypeCache.Mediation;

IMediator mediator; // Injected

var bobDoleRep = new Representative(); // Implements IRequest<Senator>
bobDoleSen = mediator.Send(bobDoleRep.Request.For<Senator>()); // Where bobDoleRep does NOT need to implement IRequest<Senator>

var campaign = mediator.Dispatch("Presidential Campaign", bobDole2);
...
await campaign;

President? bobDolePres = mediator.Send(nameof(President), bobDole2); // Send using named Rule
bobDolePres = mediator.Send(bobDole2.Request(nameof(President)).For<Senator>()); // Send using named Rule without implementing IRequest<>
bobDolePres.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 net10.0 is compatible.  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
10.1.0 102 2/16/2026
10.0.1 240 11/14/2025
10.0.0 288 11/13/2025
9.3.1 229 11/14/2025
9.3.0 299 11/13/2025
9.2.2 198 10/4/2025
9.2.1 209 9/29/2025
9.2.0 294 8/24/2025
9.1.2 207 4/25/2025
9.1.1 259 4/23/2025
9.1.0 191 2/23/2025
9.0.2 220 12/15/2024
9.0.1 182 12/6/2024
8.6.2 211 10/4/2025
8.6.1 205 9/29/2025
8.6.0 304 8/24/2025
8.5.1 254 4/24/2025
8.5.0 195 2/24/2025
8.4.3 190 12/15/2024
8.4.2 187 12/6/2024
Loading failed