PouryaKit
ReferencePackages

PouryaKit.Core

Small helpers the Kit's own packages use and your code may too.

Small helpers the Kit's own packages use and your code may too. AndAlso and OrElse compose two expression predicates into one lambda a LINQ provider such as EF Core can translate, ImplementingTypes.Of finds the concrete types of given assemblies that implement a contract, and SynchronizationContextScope blocks on asynchronous code safely where a synchronous member has to.

Install

dotnet add package PouryaKit.Core --prerelease

When to use it

  • You build a query filter from optional parts and want one predicate EF Core can translate.
  • Your application registers its own implementations of a contract it finds in its assemblies.
  • A synchronous member has to wait for asynchronous code on a thread that may have a synchronization context.

You rarely reference it yourself: PouryaKit.Cqrs, PouryaKit.Web and the packages built on them already bring it.

Quick start

There is nothing to register. From the Kit's tests, a composed predicate, the type lookup and the scope:

var composed = AboveTen().AndAlso(Even()).Compile();
Assert.Equal([typeof(Ledger)], ImplementingTypes.Of(typeof(Store<>), Fixtures));
using var scope = SynchronizationContextScope.Enter();

What you get

  • One predicate from two, with each parameter rewritten, so the provider translates the whole filter.
  • The lookup the Kit's own registrations use to find handlers, authorizers and endpoints.
  • A scope that runs a blocking wait without the current synchronization context.

A helper that belongs to one Capability lives in that Capability's package, and one that belongs to your application lives in your application.

Learn more

On this page