Convex.Shared.Business
1.0.0
dotnet add package Convex.Shared.Business --version 1.0.0
NuGet\Install-Package Convex.Shared.Business -Version 1.0.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="Convex.Shared.Business" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Convex.Shared.Business" Version="1.0.0" />
<PackageReference Include="Convex.Shared.Business" />
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 Convex.Shared.Business --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Convex.Shared.Business, 1.0.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 Convex.Shared.Business@1.0.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=Convex.Shared.Business&version=1.0.0
#tool nuget:?package=Convex.Shared.Business&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Convex.Shared.Business
Overview
Business logic and calculations for Convex microservices following SOLID principles.
Features
- IBettingCalculator: Interface for betting calculations
- BettingCalculator: Service implementation with dependency injection
- BettingConfiguration: Configurable business rules
- Service Registration: Easy DI setup
SOLID Principles
- Single Responsibility: Each class has one clear purpose
- Open/Closed: Extensible through configuration
- Liskov Substitution: Proper interface implementation
- Interface Segregation: Focused interfaces
- Dependency Inversion: Depends on abstractions
SOAR Compliance
- Scalable: Configurable business rules
- Observable: Comprehensive logging
- Available: Fault-tolerant error handling
- Reliable: Input validation and error handling
Usage
// Register services
services.AddBusinessServices();
// Or with custom configuration
services.AddBusinessServices(config =>
{
config.TaxableWinThreshold = 2000m;
config.WinTaxRate = 0.20m;
});
// Use in your service
public class MyService
{
private readonly IBettingCalculator _calculator;
public MyService(IBettingCalculator calculator)
{
_calculator = calculator;
}
public decimal CalculateWin(decimal stake, decimal odds)
{
return _calculator.CalculatePossibleWin(stake, odds);
}
}
Exception Handling
Input Validation
// ✅ Library validates inputs and throws specific exceptions
try
{
var win = _calculator.CalculatePossibleWin(-100, 2.5m); // Throws ArgumentException
}
catch (ArgumentException ex)
{
// Handle invalid input
Console.WriteLine($"Invalid input: {ex.Message}");
}
Business Logic Validation
// ✅ Business rules are enforced with exceptions
try
{
var tax = _calculator.CalculateTax(winAmount);
var winValue = _calculator.CalculateWinValue(stake, odds, 0); // Throws ArgumentException
}
catch (ArgumentException ex)
{
// Handle business rule violations
_logger.LogWarning("Business rule violation: {Message}", ex.Message);
}
Best Practice: Application-Level Error Handling
public async Task<decimal> ProcessBetAsync(decimal stake, decimal odds)
{
try
{
return await _calculator.CalculatePossibleWin(stake, odds);
}
catch (ArgumentException ex)
{
// Log and handle business rule violations
_logger.LogWarning("Invalid bet parameters: {Message}", ex.Message);
throw new InvalidBetException("Invalid bet parameters", ex);
}
}
Performance Features
High-Performance Design
- Pure Business Logic: No external dependencies in calculations
- Efficient Algorithms: Optimized mathematical operations
- Memory Efficient: Minimal object allocation
- Thread Safe: Stateless service design
- Configurable: Runtime configuration without recompilation
Exception Handling Best Practices
- Input Validation: Comprehensive parameter validation with specific exceptions
- Exception Propagation: Let exceptions bubble up naturally
- No Exception Swallowing: Clear error information for debugging
- Business Rules: Enforced through validation and exceptions
Dependencies
- Microsoft.Extensions.Logging.Abstractions
| Product | Versions 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.
-
net9.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 102 | 10/17/2025 |
Initial release of Convex.Shared.Business