ModularSystem.Core
1.29.4
See the version list below for details.
dotnet add package ModularSystem.Core --version 1.29.4
NuGet\Install-Package ModularSystem.Core -Version 1.29.4
<PackageReference Include="ModularSystem.Core" Version="1.29.4" />
paket add ModularSystem.Core --version 1.29.4
#r "nuget: ModularSystem.Core, 1.29.4"
// Install ModularSystem.Core as a Cake Addin #addin nuget:?package=ModularSystem.Core&version=1.29.4 // Install ModularSystem.Core as a Cake Tool #tool nuget:?package=ModularSystem.Core&version=1.29.4
ModularSystem Core (under development)
Build a solid basic CRUD within minutes
A library that takes care of the basic and boring stuff about creating web servers. The Modular System seeks to create a simple and modular way to automate the repetitive aspects of creating a regular web application.
Overview
This library is a group of usefull classes for daily delevopment, the goal is to always use the same code abstraction of a concept or idea, that way two diferent servers can communicate without using much, or any, specific adaptation layer. The interface exposed by one server can be parsed and understood without the need to map, type and adapt the data from the output, and that is only possible to do having a stable API model to use, that is what ModularSystem does. The 'Modular' comes from the idea to create specific modules to add functionalities to the application based on this stable interface model; the core library has some modules to add aditional features and code resusability.
CRUD
- Create and insert into database a new instance of a class
- Get one document by ID or or many by search with filters
- Update one document or many with one or multiple updates
- Delete one document by ID
Generic Typing
The entity interface works with a generic type T where T inherts from a base class, that way the library can apply the dynamic CRUD to any class. Some methods are required to be implemented or overriten, that is where the application specific logic can be wired, such as validation and presentation.
Entity Interface
The entity interface is the CRUD foundation, it contains references to the validation logic and data access layer interface. It wires everything together to create the methods exposed by the entity.
To start you need to create the data structure that will be the entity model. It is important that this model implements the IQueryableBase interface. You can extend the model from QueryableBase to auto implement everything.
Example:
using ModularSystem.Core;
class User : QueryableBase
{
public string Email { get; set; }
public string Password { get; set; }
}
The IQueryableBase interface adds properties and methods that are used by the rest of the library, so don't forget to do that. Keep in mind that you can override almost everything and set the behaviour yourself.
A presented type for this model is also required, this presented type is what the library will use as I/O models to define the adapter layer.
Example:
//...
class PresentedUser
{
public string Email { get; set; }
}
Now you are all set to create the entity for this model.
The entity class must implement the IEntity<T> interface. The easy way is to extend from Entity<T> and implement the abstract interface.
Example:
using ModularSystem.Core;
class UserEntity : Entity<User>
{
// ...
}
The entity requires, at least, the implementation of two interfaces and returning them from methods in the child class.
using ModularSystem.Core;
class UserEntity : Entity<User>
{
protected IDAO<T> dao;
protected IValidator<T> validator;
public UserEntity()
{
dao = new UserDao();
validator = new UserValidator();
}
public override IDAO<T> GetDAO() => dao;
public override IValidator<T> GetValidator() => validator;
}
Data Access Object Interface (IDAO)
The IDAO interface is the part of the app where the code to access the database lives. It is all defined in a very abstract way, this is how entity interfaces with the I/O for a given resource.
Example:
using ModularSystem.Core;
public class UserDao : IDAO<User>
{
// ...
}
The interface itself is really simple, implementing it is the real effort but, it will be done only once. The library ships with a MongoDB implementation of DAO, but you can write your own implementations like a PostgreDao class or a MySqlDao and so on.
public class UserDao : MongoDAO<User>
{
public UserDao(IMongoCollection<T> collection) : base(collection)
{
// ...
}
}
The IValidator<T> interface
The part of the app where you define the data validation for a given data structure. The validator defines a validation method that should throw exceptions in case the data is in an invalid state.
Example:
public class UserValdiator : IValidator<User>
{
// ...
}
Wiring it all together
Now that the entity has the implementations from those interfaces, it can be used by the another layer to create use cases. The entity enables writing clean code to define the desired behaviour.
public class MyUseCase
{
public void DoSomeStuff()
{
var entity = new UserEntity();
var user = new User();
var task = entity.CreateAsync(user);
}
public void DoSomeMoreStuff()
{
var entity = new UserEntity();
var context = RequestContext.System();
var request = new SearchRequest(context);
var filter = new SomeFilter();
request.AddFilter(filter);
var task<IQueryList<User>> = entity.SearchAsync(request);
}
}
You can create a basic crud ot of an entity implementation using the ApiController base class
the full namespace is ModularSystem.Web.ApiController, and it must implemente an bastract interface. The presented type here is the defined API for the app, generating GET, POST, PUT and DELETE methods for the resource.
ApiController<InnerType, OutterType> IAdapter<InnerType, OutterType>
The adapter work the same way, but you can adapt anything and have as many adapters as you like in the pipeline.
[Route("api/user")]
[ApiController]
public class UserController : ApiController<User, PresentedUser>
{
protected IEntity<User> entity;
protected IAdapter<User, PresentedUser> adapter;
public UserController(IAppContext appContext) : base(appContext.EnvToString())
{
entity = new UserEntity();
adapter = new UserAdapter();
}
protected abstract IEntity<T> GetEntity() => entity;
protected abstract IAdapter<T, PresentedT> GetAdapter() => adapter;
}
Define the adapter layer using the Adapter<TIn, TOut> class.
public class UserAdapter : Adapter<User, PresentedUser>
{
// TODO...
}
WORK IN PROGRESS ...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. |
-
net6.0
- Microsoft.AspNetCore (>= 2.2.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- MongoDB.Driver (>= 2.18.0)
- Swashbuckle.AspNetCore.Swagger (>= 6.5.0)
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.5.0)
- Swashbuckle.AspNetCore.SwaggerUI (>= 6.5.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ModularSystem.Core:
Package | Downloads |
---|---|
PlataformaOmega.IntegrationLibrary
Package Description |
|
Webql
... |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.40.0-prerelease.8 | 122 | 1/10/2024 |
1.40.0-prerelease.7 | 139 | 11/14/2023 |
1.40.0-prerelease.6 | 87 | 11/2/2023 |
1.40.0-prerelease.5 | 85 | 10/20/2023 |
1.40.0-prerelease.4 | 77 | 10/16/2023 |
1.40.0-prerelease.3 | 77 | 10/16/2023 |
1.40.0-prerelease.2 | 80 | 10/16/2023 |
1.40.0-prerelease.1 | 72 | 10/15/2023 |
1.39.1 | 206 | 9/28/2023 |
1.39.0 | 150 | 9/28/2023 |
1.38.2 | 135 | 9/27/2023 |
1.38.1 | 149 | 9/25/2023 |
1.38.0 | 136 | 9/19/2023 |
1.37.3 | 164 | 9/18/2023 |
1.37.2 | 112 | 9/18/2023 |
1.37.1 | 133 | 9/18/2023 |
1.37.0 | 168 | 9/13/2023 |
1.36.0 | 181 | 9/12/2023 |
1.35.6 | 161 | 9/12/2023 |
1.35.5 | 163 | 9/12/2023 |
1.35.4 | 169 | 9/11/2023 |
1.35.3 | 160 | 9/7/2023 |
1.35.2 | 144 | 9/6/2023 |
1.35.1 | 162 | 9/6/2023 |
1.35.0 | 167 | 9/6/2023 |
1.35.0-prerelease.42 | 100 | 8/31/2023 |
1.35.0-prerelease.41 | 80 | 8/31/2023 |
1.35.0-prerelease.40 | 101 | 8/30/2023 |
1.35.0-prerelease.39 | 94 | 8/30/2023 |
1.35.0-prerelease.38 | 100 | 8/29/2023 |
1.35.0-prerelease.37 | 91 | 8/27/2023 |
1.35.0-prerelease.36 | 86 | 8/26/2023 |
1.35.0-prerelease.35 | 86 | 8/26/2023 |
1.35.0-prerelease.34 | 83 | 8/26/2023 |
1.35.0-prerelease.33 | 82 | 8/26/2023 |
1.35.0-prerelease.32 | 89 | 8/25/2023 |
1.35.0-prerelease.31 | 100 | 8/25/2023 |
1.35.0-prerelease.30 | 91 | 8/25/2023 |
1.35.0-prerelease.29 | 92 | 8/25/2023 |
1.35.0-prerelease.28 | 84 | 8/25/2023 |
1.35.0-prerelease.27 | 90 | 8/25/2023 |
1.35.0-prerelease.26 | 80 | 8/25/2023 |
1.35.0-prerelease.25 | 87 | 8/25/2023 |
1.35.0-prerelease.24 | 86 | 8/25/2023 |
1.35.0-prerelease.23 | 93 | 8/24/2023 |
1.35.0-prerelease.22 | 91 | 8/24/2023 |
1.35.0-prerelease.21 | 86 | 8/23/2023 |
1.35.0-prerelease.20 | 82 | 8/23/2023 |
1.35.0-prerelease.19 | 80 | 8/23/2023 |
1.35.0-prerelease.18 | 93 | 8/19/2023 |
1.35.0-prerelease.17 | 86 | 8/19/2023 |
1.35.0-prerelease.16 | 95 | 8/19/2023 |
1.35.0-prerelease.15 | 80 | 8/18/2023 |
1.35.0-prerelease.14 | 86 | 8/16/2023 |
1.35.0-prerelease.13 | 83 | 8/16/2023 |
1.35.0-prerelease.12 | 87 | 8/15/2023 |
1.35.0-prerelease.11 | 95 | 8/14/2023 |
1.35.0-prerelease.10 | 94 | 8/13/2023 |
1.35.0-prerelease.9 | 94 | 8/13/2023 |
1.35.0-prerelease.8 | 98 | 8/9/2023 |
1.35.0-prerelease.7 | 109 | 8/2/2023 |
1.35.0-prerelease.6 | 96 | 8/2/2023 |
1.35.0-prerelease.5 | 103 | 8/2/2023 |
1.35.0-prerelease.4 | 88 | 8/2/2023 |
1.35.0-prerelease.2 | 128 | 8/1/2023 |
1.35.0-prerelease.1 | 105 | 7/25/2023 |
1.34.3 | 188 | 7/14/2023 |
1.34.2 | 209 | 7/11/2023 |
1.34.1 | 190 | 7/11/2023 |
1.34.0 | 155 | 7/11/2023 |
1.33.1 | 187 | 7/6/2023 |
1.33.0 | 191 | 7/6/2023 |
1.32.7 | 188 | 5/31/2023 |
1.32.6 | 243 | 5/31/2023 |
1.32.5 | 184 | 5/31/2023 |
1.32.4 | 176 | 5/31/2023 |
1.32.3 | 193 | 5/30/2023 |
1.32.2 | 237 | 5/30/2023 |
1.32.1 | 228 | 5/30/2023 |
1.32.0 | 169 | 5/26/2023 |
1.31.6 | 208 | 4/25/2023 |
1.31.5 | 214 | 4/25/2023 |
1.31.4 | 291 | 4/24/2023 |
1.31.3 | 226 | 4/21/2023 |
1.31.2 | 196 | 4/20/2023 |
1.31.1 | 138 | 4/14/2023 |
1.31.0 | 200 | 4/6/2023 |
1.30.0 | 137 | 4/4/2023 |
1.29.18 | 459 | 3/18/2023 |
1.29.17 | 338 | 3/18/2023 |
1.29.16 | 266 | 3/16/2023 |
1.29.15 | 266 | 3/16/2023 |
1.29.14 | 254 | 3/14/2023 |
1.29.13 | 538 | 3/9/2023 |
1.29.12 | 530 | 3/6/2023 |
1.29.11 | 276 | 3/3/2023 |
1.29.10 | 268 | 3/3/2023 |
1.29.9 | 362 | 3/2/2023 |
1.29.8 | 353 | 3/2/2023 |
1.29.7 | 629 | 3/1/2023 |
1.29.6 | 265 | 3/1/2023 |
1.29.5 | 361 | 2/27/2023 |
1.29.4 | 274 | 2/27/2023 |
1.29.3 | 285 | 2/25/2023 |
1.29.2 | 298 | 2/24/2023 |
1.29.1 | 311 | 2/24/2023 |
1.29.0 | 290 | 2/24/2023 |
1.28.4 | 277 | 2/22/2023 |
1.28.3 | 371 | 2/18/2023 |
1.28.2 | 291 | 2/18/2023 |
1.28.1 | 300 | 2/17/2023 |
1.28.0 | 457 | 2/16/2023 |
1.27.0 | 298 | 2/8/2023 |
1.26.3 | 307 | 2/7/2023 |
1.26.2 | 308 | 2/7/2023 |
1.26.1 | 297 | 2/7/2023 |
1.26.0 | 305 | 2/6/2023 |
1.25.21 | 315 | 2/4/2023 |
1.25.20 | 421 | 2/4/2023 |
1.25.19 | 312 | 2/4/2023 |
1.25.18 | 309 | 2/4/2023 |
1.25.17 | 299 | 2/3/2023 |
1.25.16 | 329 | 2/3/2023 |
1.25.15 | 306 | 1/28/2023 |
1.25.14 | 317 | 1/28/2023 |
1.25.13 | 317 | 1/27/2023 |
1.25.12 | 347 | 1/27/2023 |
1.25.11 | 477 | 1/27/2023 |
1.25.10 | 335 | 1/27/2023 |
1.25.9 | 416 | 1/20/2023 |
1.25.8 | 354 | 1/20/2023 |
1.25.7 | 352 | 1/20/2023 |
1.25.6 | 363 | 1/20/2023 |
1.25.5 | 332 | 1/20/2023 |
1.25.4 | 410 | 1/20/2023 |
1.25.3 | 334 | 1/20/2023 |
1.25.2 | 332 | 1/20/2023 |
1.25.1 | 341 | 1/19/2023 |
1.25.0 | 355 | 1/19/2023 |
1.24.4 | 583 | 1/13/2023 |
1.24.3 | 366 | 1/13/2023 |
1.24.2 | 344 | 1/13/2023 |
1.24.1 | 369 | 1/13/2023 |
1.24.0 | 345 | 1/13/2023 |
1.23.0 | 605 | 9/14/2022 |
1.22.0 | 509 | 8/27/2022 |
1.21.0 | 491 | 8/16/2022 |
1.20.1 | 526 | 8/4/2022 |
1.20.0 | 647 | 7/23/2022 |
1.19.3 | 536 | 7/8/2022 |
1.19.2 | 546 | 7/8/2022 |
1.19.1 | 936 | 7/7/2022 |
1.19.0 | 517 | 7/7/2022 |
1.18.10 | 662 | 7/6/2022 |
1.18.9 | 948 | 7/2/2022 |
1.18.8 | 518 | 7/2/2022 |
1.18.7 | 548 | 7/2/2022 |
1.18.6 | 544 | 7/2/2022 |
1.18.5 | 521 | 7/2/2022 |
1.18.4 | 518 | 7/2/2022 |
1.18.3 | 519 | 7/1/2022 |
1.18.2 | 531 | 6/28/2022 |
1.18.1 | 567 | 6/28/2022 |
1.18.0 | 511 | 6/27/2022 |
1.17.0 | 542 | 6/27/2022 |
1.16.8 | 558 | 5/16/2022 |
1.16.7 | 568 | 5/12/2022 |
1.16.6 | 572 | 5/10/2022 |
1.16.5 | 589 | 5/10/2022 |
1.16.4 | 570 | 5/10/2022 |
1.16.3 | 568 | 5/10/2022 |
1.16.2 | 590 | 4/30/2022 |
1.16.1 | 579 | 4/30/2022 |
1.16.0 | 577 | 4/30/2022 |
1.15.2 | 587 | 4/28/2022 |
1.15.1 | 570 | 4/27/2022 |
1.15.0 | 1,515 | 4/27/2022 |
1.14.8 | 588 | 4/1/2022 |
1.14.7 | 596 | 4/1/2022 |
1.14.6 | 604 | 4/1/2022 |
1.14.5 | 557 | 4/1/2022 |
1.14.4 | 624 | 3/27/2022 |
1.14.3 | 577 | 3/26/2022 |
1.14.2 | 589 | 3/25/2022 |
1.14.1 | 1,022 | 3/23/2022 |
1.14.0 | 571 | 3/23/2022 |
1.13.1 | 607 | 3/22/2022 |
1.13.0 | 584 | 3/22/2022 |
1.12.2 | 585 | 3/22/2022 |
1.12.1 | 776 | 3/22/2022 |
1.12.0 | 578 | 3/22/2022 |
1.11.2 | 618 | 3/11/2022 |
1.11.1 | 606 | 3/10/2022 |
1.11.0 | 587 | 3/10/2022 |
1.10.0 | 737 | 3/7/2022 |
1.9.2 | 635 | 3/3/2022 |
1.9.1 | 605 | 3/3/2022 |
1.9.0 | 1,683 | 2/26/2022 |
1.8.3 | 591 | 2/26/2022 |
1.8.2 | 609 | 2/1/2022 |
1.8.1 | 613 | 1/24/2022 |
1.8.0 | 621 | 1/24/2022 |
1.7.1 | 664 | 1/19/2022 |
1.7.0 | 618 | 1/19/2022 |
1.6.0 | 613 | 1/19/2022 |
1.5.0 | 638 | 1/19/2022 |
1.4.3 | 515 | 1/14/2022 |
1.4.2 | 512 | 1/14/2022 |
1.4.1 | 620 | 1/13/2022 |
1.4.0 | 515 | 1/13/2022 |
1.3.0 | 661 | 1/12/2022 |
1.2.0 | 522 | 1/11/2022 |
1.1.3 | 532 | 1/11/2022 |
1.1.2 | 514 | 1/11/2022 |
1.1.1 | 524 | 1/11/2022 |
1.1.0 | 524 | 1/11/2022 |
New Features.