Slon.SharedAssets
0.1.0
See the version list below for details.
dotnet add package Slon.SharedAssets --version 0.1.0
NuGet\Install-Package Slon.SharedAssets -Version 0.1.0
<PackageReference Include="Slon.SharedAssets" Version="0.1.0" />
paket add Slon.SharedAssets --version 0.1.0
#r "nuget: Slon.SharedAssets, 0.1.0"
// Install Slon.SharedAssets as a Cake Addin #addin nuget:?package=Slon.SharedAssets&version=0.1.0 // Install Slon.SharedAssets as a Cake Tool #tool nuget:?package=Slon.SharedAssets&version=0.1.0
Slon
Overview
Welcome to the Slon library, which aims to demonstrate Domain-Driven Design (DDD) and Clean Architecture principles in a .NET context. This library provides abstractions, interfaces, and base classes that can be used to build well-structured and maintainable applications.
Features
- Implement DDD concepts like entities, domain events, and aggregates.
- Define interfaces for domain-driven architecture.
- Embrace Clean Architecture by providing clear separation of concerns.
- Utilize MediatR for efficient event-driven communication.
- Includes a Unit of Work pattern for data persistence.
- Designed for extensibility and customization.
Installation
Install the library via NuGet Package Manager:
dotnet add package Your.Package.Name
Usage
1. Install the Package
First, install the library via NuGet Package Manager:
dotnet add package Your.Package.Name
2. Implement Your Domain Logic
Build your domain logic using the abstractions and interfaces provided by the library. Define your entities, value objects, aggregates, and domain events that model your application's core concepts and business rules.
// Example domain entity
public class Product : Entity<Guid>
{
public string Name { get; set; }
// Add more properties and methods...
}
3. Follow Clean Architecture
Organize your application using the Clean Architecture principles to ensure a clear separation of concerns. Divide your solution into layers such as Presentation, Application, Domain, and Infrastructure. This helps maintain a modular and maintainable codebase.
4. MediatR Communication
Leverage MediatR to enable event-driven communication within your application. Publish domain events using the MediatR framework, allowing different parts of your application to react to events without direct dependencies.
// Publishing a domain event
var product = new Product();
var productCreatedEvent = new ProductCreatedEvent(product);
await _mediator.Publish(productCreatedEvent);
5. Unit of Work
Use the provided interfaces for implementing the Unit of Work pattern. This helps manage your data persistence and transactions efficiently.
// Example repository
public class ProductRepository : IRepository<Product>
{
private readonly IDbContext _context;
public ProductRepository(IDbContext context)
{
_context = context;
}
public async Task<Product> GetByIdAsync(Guid id)
{
return await _context.Products.FirstOrDefaultAsync(p => p.Id == id);
}
// Implement other repository methods...
}
6. Testing
Write unit tests for your domain logic, application services, and other components. Utilize mocking frameworks to isolate the units you're testing from their dependencies.
// Example unit test using NUnit and Moq
[TestFixture]
public class ProductServiceTests
{
[Test]
public void CreateProduct_ShouldPublishProductCreatedEvent()
{
var mockMediator = new Mock<IMediator>();
var productService = new ProductService(mockMediator.Object);
var product = productService.CreateProduct("Sample Product");
mockMediator.Verify(m => m.Publish(It.IsAny<ProductCreatedEvent>(), default), Times.Once);
}
}
7. Documentation
Provide clear and concise documentation for your library. Include inline comments, XML documentation, and example use cases to help developers understand and effectively use your library's features.
For more detailed examples and information, check the Documentation directory.
Contributing
We welcome contributions from the community! If you have ideas, bug reports, or new features to propose, feel free to open an issue or submit a pull request. Please review our Contribution Guidelines before contributing.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Please replace placeholders like `Your.Package.Name`, and customize the code examples and explanations based on your library's features and concepts. Also, make sure to create appropriate directories for documentation, such as `docs/`, and adjust the links accordingly.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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 was computed. 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. |
-
net7.0
- MediatR.Contracts (>= 2.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.