Moclawr.Shared 2.0.1

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

Moclawr.Shared

NuGet

Overview

Moclawr.Shared provides fundamental interfaces, response models, and utility classes shared across all Moclawr libraries. It establishes consistent patterns for entity design, error handling, and API responses.

Features

  • Entity Interfaces: Base interfaces for entity modeling with typed IDs
  • Standard Response Models: Unified response types for APIs and services
  • Exception Types: Custom exceptions for common business scenarios
  • Utility Classes: Helpers for paging, password security, and response formatting
  • JSON Settings: Default serialization configuration for consistent data handling

Installation

dotnet add package Moclawr.Shared

Usage Examples

Entity Interfaces

// Create an entity that implements the IEntity interface
public class Customer : IEntity<Guid>
{
    public Guid Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public string Email { get; set; } = string.Empty;
}

Response Models

// Create a success response with data
var response = new Response<CustomerDto>
{
    Data = customerDto,
    IsSuccess = true,
    StatusCode = 200,
    Message = "Customer retrieved successfully"
};

// Create an error response
var errorResponse = Response.Error("Customer not found", 404);

Utility Classes

// Create a paging object for list queries
var paging = new Paging(pageIndex: 1, pageSize: 20);

// Hash a password securely
string hashedPassword = PasswordHasher.HashPassword("userPassword");
bool isValid = PasswordHasher.VerifyPassword(hashedPassword, "userPassword");

Integration with Other Moclawr Packages

Moclawr.Shared serves as a dependency for virtually all other Moclawr packages:

  • Moclawr.Core: For extension methods and utilities
  • Moclawr.Domain: For entity base classes and interfaces
  • Moclawr.EfCore and Moclawr.MongoDb: For repository contracts and entity requirements
  • Moclawr.MinimalAPI: For standardized response handling

Requirements

  • .NET 9.0 or higher

License

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

Product 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

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Moclawr.Shared:

Package Downloads
Moclawr.MinimalAPI

Minimal API utilities with MediatR integration for .NET 9. Provides a class-based approach to endpoint definition with built-in CQRS support and SwaggerUI.

Moclawr.Core

Core utilities and base types for the moclaw project. Provides essential utility extension methods and base functionality for .NET applications.

Moclawr.Domain

Domain entities and builders for the moclaw project. Provides base entity types and builder interfaces for entity construction and query building.

Moclawr.EfCore

EF Core integration for the moclaw project. Provides base context, repositories, and builders for relational data access.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 137 5/24/2025
2.0.0 102 5/24/2025
1.0.3 97 5/24/2025
1.0.2 191 5/22/2025

Added improved XML documentation and bug fixes.