MooVC.Infrastructure.Serialization.MessagePack 9.3.0-beta.5

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

MooVC NuGet GitHub

The MooVC library contains a collection of functionalities common to many applications, gathered to support the rapid development of a wide variety of applications targeting multiple platforms.

MooVC was originally created as a PHP based framework back in 2009, intended to support the rapid development of object-oriented web applications based on the Model-View-Controller design pattern that were to be rendered in well-formed XHTML. It is from this that MooVC gets its name - the Model-object-oriented-View-Controller.

While the original MooVC PHP based framework has long since been deprecated, many of the lessons learned from it have formed the basis of solutions the author has since developed. This library, and those related to it, are all intended to support the rapid development of high quality software that addresses a variety of use-cases.

Table of Contents

Getting Started

Install the core package:

dotnet add package MooVC

Add optional infrastructure packages as needed; each capability below lists extensions that provide additional implementations.

Target Frameworks

MooVC libraries target .NET Standard 2.0, .NET 8.0, .NET 9.0, and .NET 10.0, ensuring compatibility across current and long-term supported platforms.

Capabilities

MooVC packages a set of reusable building blocks.

Compression

Compression enhances your code by shrinking payloads and eliminating boilerplate through the ICompressor abstraction with built-in Brotli, GZip, and Deflate implementations.

Usage

Compress or decompress streams and byte arrays with a single call.

ICompressor provider = new GZipCompressor();
IEnumerable<byte> compressed = await provider.Compress(original, CancellationToken.None);
IEnumerable<byte> restored = await provider.Decompress(compressed, CancellationToken.None);
Infrastructure Options
  • MooVC.Infrastructure.Compression.LZ4 – LZ4 compressor implementation for high throughput scenarios

Serialization and Cloning

Serialization and cloning streamline the persistence and duplication of complex objects through consistent ISerializer and ICloner interfaces. The core library includes a System.Text.Json implementation and supports optional compression.

Usage

Serialize or deserialize objects and create deep clones with a single call.

var serializer = new MooVC.Serialization.Json.Serializer();
IEnumerable<byte> serializedOrder = await serializer.Serialize(purchaseOrder, CancellationToken.None);
Order clonedOrder = await serializer.Deserialize<Order>(serializedOrder, CancellationToken.None);
Infrastructure Options
  • MooVC.Infrastructure.Serialization.Json.Newtonsoft – Newtonsoft.Json serializer
  • MooVC.Infrastructure.Serialization.MessagePack – high performance binary serializer
  • MooVC.Infrastructure.Serialization.Bson.Newtonsoft – BSON serializer
  • MooVC.Infrastructure.Serialization.Apex – Apex binary serializer

Paging

Paging slices large data sets into predictable chunks using Directive and Page<T> types, preventing timeouts and lowering memory usage.

Usage

Construct a directive and turn queries into pages.

Directive request = new(limit: 25, page: 1);
Page<Customer> customerPage = customerQuery.ToPage(request);
Infrastructure Options

Provided in the core library; no additional packages required.

Threading

Threading helpers coordinate asynchronous initialization and exclusive access to shared resources, reducing concurrency errors.

Helpers include:

  • Initializer<T> for asynchronous lazy initialization
  • Coordinator<T> for mutual exclusion by context
Usage
var initializer = new Initializer<Configuration>(_ => LoadConfigAsync());
Configuration configuration = await initializer.Initialize(CancellationToken.None);

var coordinator = new Coordinator<string>();
using IContext<string> context = await coordinator.Apply("orders", CancellationToken.None);
// exclusive work
Infrastructure Options

Provided in the core library; no additional packages required.

Hosting

Hosting helpers safely start and stop long-running services across threads.

Helpers include:

  • ThreadSafeHostedService to coordinate multiple hosted services
Usage
var service = new ThreadSafeHostedService(example, logger);
await service.StartAsync(CancellationToken.None);
// ...
await service.StopAsync(CancellationToken.None);
Infrastructure Options

Provided in the core library; no additional packages required.

LINQ and Collection Extensions

LINQ and collection extensions keep queries expressive and succinct. Each extension below targets a common scenario and includes an API-style summary for quick reference.

WhereIf

Conditionally apply a predicate only when a supplied condition is met.

Signature
public static IEnumerable<T>? WhereIf<T>(
    this IEnumerable<T>? enumeration,
    bool isApplicable,
    Func<T, bool> predicate)

public static IEnumerable<T>? WhereIf<T>(
    this IEnumerable<T>? enumeration,
    Func<bool> condition,
    Func<T, bool> predicate)
Parameters
  • enumeration – The sequence to filter.
  • isApplicable / condition – Determines whether the filter is applied.
  • predicate – The condition used to filter items.
Returns
  • The filtered sequence if the condition is satisfied; otherwise, the original sequence.
Example
IEnumerable<Order> activeOrders = allOrders.WhereIf(
    includeOnlyActive,
    order => order.IsActive);
ForAll

Execute an action for every element in the sequence, synchronously or asynchronously.

Signature
public static void ForAll<T>(this IEnumerable<T>? items, Action<T> action)

public static Task ForAll<T>(this IEnumerable<T>? items, Func<T, Task> operation)
Parameters
  • items – The sequence of items to iterate.
  • action / operation – The delegate executed for each item.
Returns
  • A Task representing completion for the asynchronous overload; otherwise, nothing.
Example
await activeOrders.ForAll(ProcessOrderAsync);
Combine

Append additional items to an existing sequence without creating temporary collections.

Signature
public static IEnumerable<T> Combine<T>(this IEnumerable<T>? source, T instance)

public static IEnumerable<T> Combine<T>(this IEnumerable<T>? source, IEnumerable<T>? instances)
Parameters
  • source – The original sequence.
  • instance / instances – Items to append to the sequence.
Returns
  • A sequence containing the original elements followed by the appended items.
Example
IEnumerable<int> combined = existing.Combine(new[] { 4, 5 });
ToIndex

Create a dictionary keyed by values selected from each element.

Signature
public static IDictionary<TSubject, TValue> ToIndex<TSubject, TValue>(
    this IEnumerable<TSubject>? source,
    Func<TSubject, TValue> selector)

public static IDictionary<TSubject, TTransform> ToIndex<TSubject, TTransform, TValue>(
    this IEnumerable<TSubject>? source,
    Func<TSubject, TValue> selector,
    Func<TValue, TTransform> transform)
Parameters
  • source – The sequence to index.
  • selector – Projects each element into a key.
  • transform – Converts the selected value before insertion.
Returns
  • A dictionary containing keys and values generated from the sequence.
Example
IDictionary<Guid, Order> orderLookup = allOrders
    .ToIndex(order => order.Id);
AddRange

Insert multiple items into an ICollection<T> without manual loops.

Signature
public static void AddRange<T>(this ICollection<T> target, IEnumerable<T>? items)
Parameters
  • target – The collection receiving new items.
  • items – The elements to add to the collection.
Returns
  • Nothing. The target collection is updated in place.
Example
ICollection<Order> pending = new List<Order>();
pending.AddRange(@new);
Replace

Clear an ICollection<T> and populate it with a replacement sequence.

Signature
public static void Replace<T>(this ICollection<T> target, IEnumerable<T>? replacements)
Parameters
  • target – The collection whose contents are to be replaced.
  • replacements – The new elements for the collection.
Returns
  • Nothing. The target collection is overwritten with replacements.
Example
ICollection<Order> processed = GetExistingOrders();
processed.Replace(latest);
Infrastructure Options

Provided in the core library; no additional packages required.

Dynamic and I/O Helpers

Dynamic and I/O helpers reduce repetitive plumbing when working with dynamic objects, exceptions, and streams.

Usage

Utilities for cloning ExpandoObject, navigating exception trees, working with streams, and more.

dynamic cloned = original.Clone();
Infrastructure Options

Provided in the core library; no additional packages required.

These features can be adopted piecemeal – pick the utilities that help your project and ignore the rest.

Why Use MooVC?

  • Accelerated Development – Reuse battle tested helpers instead of re‑implementing common infrastructure.
  • Consistency – Uniform APIs for serialization, compression, and coordination keep code bases consistent across projects.
  • Productivity – Extension methods and abstractions simplify code, letting software engineers focus on business logic.

Contributions and feedback are welcome.

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 is compatible.  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.  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 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. 
.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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.