Moclawr.Shared
2.0.1
dotnet add package Moclawr.Shared --version 2.0.1
NuGet\Install-Package Moclawr.Shared -Version 2.0.1
<PackageReference Include="Moclawr.Shared" Version="2.0.1" />
<PackageVersion Include="Moclawr.Shared" Version="2.0.1" />
<PackageReference Include="Moclawr.Shared" />
paket add Moclawr.Shared --version 2.0.1
#r "nuget: Moclawr.Shared, 2.0.1"
#addin nuget:?package=Moclawr.Shared&version=2.0.1
#tool nuget:?package=Moclawr.Shared&version=2.0.1
Moclawr.Shared
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 | 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. |
-
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.
Added improved XML documentation and bug fixes.