PosSharp.Abstractions 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package PosSharp.Abstractions --version 1.0.1
                    
NuGet\Install-Package PosSharp.Abstractions -Version 1.0.1
                    
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="PosSharp.Abstractions" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PosSharp.Abstractions" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="PosSharp.Abstractions" />
                    
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 PosSharp.Abstractions --version 1.0.1
                    
#r "nuget: PosSharp.Abstractions, 1.0.1"
                    
#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 PosSharp.Abstractions@1.0.1
                    
#: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=PosSharp.Abstractions&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=PosSharp.Abstractions&version=1.0.1
                    
Install as a Cake Tool

PosSharp

License: MIT .NET Core NuGet Core NuGet Abstractions CI

PosSharp is a platform-agnostic, reactive UPOS (Unified POS) framework for .NET. It provides a modern implementation of the UPOS standard, decoupling core POS logic from platform-specific SDK dependencies like the legacy POS for .NET (OPOS) or Windows-only components.

๐Ÿš€ Key Features

  • Modern C# Implementation: Fully utilizes C# 12+ features (Primary Constructors, etc.) and targets .net10.0. Supports older platforms via PolySharp.
  • Reactive State Management: Built-in state synchronization using R3. Properties like State, PowerState, and ResultCode are exposed as reactive observables.
  • Mediator Architecture: Centralized "Single Source of Truth" via the Mediator pattern, ensuring all properties (DataCount, IsOpen, etc.) stay perfectly in sync across asynchronous operations.
  • Task-Based Asynchronous API: Modern asynchronous implementation of standard UPOS operations (OpenAsync, ClaimAsync, SetEnabledAsync).
  • Power Management: Comprehensive support for power reporting and state notifications (PowerNotify) integrated directly into the base abstraction.
  • Zero Build Warnings: Maintained at the highest quality with 100% XML documentation and strict static analysis.

๐Ÿ“ฆ Packages

Package Description
PosSharp.Abstractions Core interfaces, enums, and event records. Perfect for client-side dependencies.
PosSharp.Core The engine. Includes base classes, lifecycle management, and reactive mediator.

Installation

# To implement a device
dotnet add package PosSharp.Core

# For pure abstractions
dotnet add package PosSharp.Abstractions

๐Ÿ—๏ธ Architecture

PosSharp utilizes a sophisticated architecture to handle the complexity of the UPOS standard while maintaining clean, maintainable code.

Mediator-Based State Management

Each device delegates its state and property management to a UposMediator. This ensures that when a device transitions (e.g., from Idle to Enabled), all related properties and reactive event streams are updated atomically.

Flexible Lifecycle Management

Device transitions are governed by a UposLifecycleManager, allowing developers to implement custom lifecycle handlers or use the StandardLifecycleHandler for typical UPOS compliance.

graph TD
    Device[IUposDevice] --> Base[UposDeviceBase]
    Base --> Mediator[UposMediator]
    Base --> Lifecycle[UposLifecycleManager]
    Mediator -- Syncs --> Props[Reactive Properties]
    Mediator -- Pushes --> Events[Reactive Events]

๐Ÿ› ๏ธ Usage

To create a new UPOS device, simply inherit from UposDeviceBase:

using PosSharp.Abstractions;
using PosSharp.Core;

// Example implementation of a CashChanger
public class MyCashChanger : UposDeviceBase
{
    // Override required abstract members
    protected override Task OnOpenAsync(CancellationToken ct) => Task.CompletedTask;
    protected override Task OnCloseAsync(CancellationToken ct) => Task.CompletedTask;
    protected override Task OnClaimAsync(int timeout, CancellationToken ct) => Task.CompletedTask;
    protected override Task OnReleaseAsync(CancellationToken ct) => Task.CompletedTask;
    protected override Task OnEnableAsync(CancellationToken ct) => Task.CompletedTask;
    protected override Task OnDisableAsync(CancellationToken ct) => Task.CompletedTask;

    protected override Task<string> OnCheckHealthAsync(HealthCheckLevel level, CancellationToken ct)
    {
        return Task.FromResult("Internal:OK");
    }

    protected override Task OnDirectIOAsync(int command, int data, object obj, CancellationToken ct) => Task.CompletedTask;
    protected override Task OnClearInputAsync(CancellationToken ct) => Task.CompletedTask;
    protected override Task OnClearOutputAsync(CancellationToken ct) => Task.CompletedTask;
    
    // Use the protected helpers to update internal state
    public void SimulateCashAdded()
    {
        // DataCount is automatically synchronized via the Mediator
        UpdateDataCount(DataCount + 1);
    }
}

Consuming a Device (Client-Side)

If you are just consuming a device (e.g., in a UI or business logic layer), you only need to depend on PosSharp.Abstractions and use the reactive interfaces:

using PosSharp.Abstractions;
using R3;

public class DeviceMonitor(IUposDevice device)
{
    public void Initialize()
    {
        // React to state changes
        device.State
            .Subscribe(state => Console.WriteLine($"Device state: {state}"));

        // Handle data events
        device.DataEvents
            .Subscribe(e => Console.WriteLine($"Data received: {e.Status}"));
    }

    public async Task StartAsync()
    {
        await device.OpenAsync();
        await device.ClaimAsync(1000);
        await device.SetEnabledAsync(true);
    }
}

๐Ÿงช Testing

PosSharp is built with testability in mind. It includes a comprehensive test suite and provides stubs to help you test your own implementations.

dotnet test

๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

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.
  • net10.0

    • R3 (>= 1.3.0)

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PosSharp.Abstractions:

Package Downloads
PosSharp.Core

Standard implementation of the PosSharp UPOS framework, including lifecycle management and mediator patterns.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 103 5/11/2026
1.2.0 113 4/29/2026
1.1.0 107 4/27/2026
1.0.1 100 4/23/2026
1.0.0 113 4/23/2026
1.0.0-preview.1 51 4/29/2026