ModularSystem.Core 1.39.1

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package ModularSystem.Core --version 1.39.1
NuGet\Install-Package ModularSystem.Core -Version 1.39.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="ModularSystem.Core" Version="1.39.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ModularSystem.Core --version 1.39.1
#r "nuget: ModularSystem.Core, 1.39.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.
// Install ModularSystem.Core as a Cake Addin
#addin nuget:?package=ModularSystem.Core&version=1.39.1

// Install ModularSystem.Core as a Cake Tool
#tool nuget:?package=ModularSystem.Core&version=1.39.1

ModularSystem Core Module (Under Development)

Build a Solid Basic CRUD Within Minutes

This library streamlines the foundational tasks of setting up web servers. ModularSystem aims to automate repetitive aspects of web application development in a modular and simple manner.

Overview

ModularSystem provides a collection of useful classes for daily development tasks. The core philosophy is to maintain a stable API model to facilitate communication between different servers without requiring specific adaptation layers. This enables parsing and understanding the interface exposed by a server without data mapping, typing, or adaptation. The term 'Modular' reflects the system's extensibility, allowing developers to add modules to enhance functionality and promote code reuse.

CRUD Operations

The library offers complete CRUD (Create, Read, Update, Delete) operations, featuring a well-defined query mechanism based on Expression trees.

Generics

The entity interface employs a generic type T, which inherits from a base class. This design allows the library to apply dynamic CRUD operations to any class. Developers will need to implement or override specific methods, where application-specific logic like validation and presentation can be added.

Entity Interface

The Entity Interface serves as the foundation for CRUD operations. It consolidates validation logic, data access layers, and much more to expose methods through the entity.

Usage

Initializing the Library

For the library to function correctly, it's essential to initialize it before use. This step ensures that all modules and components are properly set up and ready for use.

Step-by-step Guide:
  • Import the necessary namespace: Add the ModularSystem.Core namespace to your application.

  • Call the Initializer: Use the Initializer.Run() method to initialize the library.

Example:

using ModularSystem.Core;

namespace MyApp;

public static class Program
{
    public static void Main(string[] args)
    {
        Initializer.Run();
    }
}

Getting Started

  • To begin, create the data structure for the entity model. This model should implement the IQueryableModel interface. Extend from QueryableModel to automatically implement all required methods.

Example:

using ModularSystem.Core;

namespace MyApp;

public class User : QueryableModel
{
    public string Email { get; set; }
    public string Password { get; set; }
}
  • Implement the IEntity<T> interface in the entity class. One approach is to extend from Entity<T> and implement the abstract methods.

Example:

using ModularSystem.Core;

namespace MyApp;
  
public class UserEntity : Entity<User>
{
    // ...
}
  • Now call the entity anywhere to create a usecase.

Example:

namespace MyApp;
  
public class Program
{
    public static async Task Main()
    {
        using var userEntity = new UserEntity();
        
        var user = new User() 
        { 
            Email = "foo@bar.baz", 
            Password = "super-password" 
        };
        
        var userId = await entity.CreateAsync(user);
    }
}

Note that the raw entity class requires implementation of certain methods and properties:

Example:

using ModularSystem.Core;

namespace MyApp;

public class UserEntity : Entity<User>
{
    protected IDataAccessObject<User> DataAccessObject { get; }

    public UserEntity()
    {
        //...
    }
    
    protected override MemberExpression CreateIdSelectorExpression  (ParameterExpression parameter)
    {
        //...
    }
    
    protected override object? TryParseId(string id)
    {
        //...
    }
}

The library also provides an Entity Framework implementation, with additional modules offering other implementations.

Example:

using ModularSystem.Core;
using ModularSystem.EntityFramework;
    
namespace MyApp;

public class UserEntity : EFEntity<User>
{
    protected IDataAccessObject<User> DataAccessObject { get; }
    
    public UserEntity()
    {
        //...
    }
}

Data Access Object Interface (IDAO)

The IDataAccessObject interface houses the code for database access, serving as the entity's I/O interface for a given resource. The core library includes embedded implementations like EFCoreDataAccessObject.

Example:

using ModularSystem.Core;
using ModularSystem.EntityFramework;

namespace MyApp;

class UserEntity : EFEntity<User>
{
    protected IDataAccessObject<User> DataAccessObject { get; }

    public UserEntity()
    {
        DataAccessObject = new EFCoreDataAccessObject<User>(new MyDbContext());
    }
}

IValidator<T> Interface

Here you define data validation rules for specific data structures. Implement a validation method to return or throw exceptions if the data is in an invalid state.

Example:

using ModularSystem.Core;
using ModularSystem.EntityFramework;

namespace MyApp;

public class UserValidator : IValidator<User>
{
    public Task<Exception?> ValidateAsync(User instance)
    {
        //...
    }
}

class UserEntity : EFEntity<User>
{
    protected IDataAccessObject<User> DataAccessObject { get; }

    public UserEntity()
    {
        DataAccessObject = new EFCoreDataAccessObject<User>(new MyDbContext());
        Validator = new UserValidator();
    }
}

Wiring it All Together

Entities can be utilized by other layers to create use cases, thus enabling clean and desired code behavior.

Example:

using ModularSystem.Core;

namespace MyApp;

public class MyUseCase
{
    public async Task DoSomeStuff()
    {
        using var entity = new UserEntity();
        var user = new User();
        var id = await entity.CreateAsync(user);
    }

    public async Task DoSomeMoreStuff()
    {
        using var entity = new UserEntity();

        var query = new Query<User>()
            .SetFilter(user => user.Email == "foo@bar.baz");

        var queryResult = await entity.QueryAsync(query);
    }
}

API Controller

Create a basic CRUD API with the ApiController base class, which generates GET, POST, PUT, and DELETE endpoints.

Example:

using ModularSystem.Core;
using ModularSystem.Web;

namespace MyApp;

[Route("api/user")]
public class UserController : CrudController<User>
{
    protected override Entity<User> Entity => new UserEntity();
}

Accessing the API with a CRUD Client from another C# application.

You can access the API created by the CrudController through an instance of CrudClient<T>.

Note: For seamless communication, it's crucial that both applications either reference the same resource assembly or have exact replicas of it. In this context, the User class is the shared resource. It's imperative that the shared resource has a matching type fullname. For instance, the class MyApp.User should be present in both applications, even if they reside in separate assemblies or originate from different version sources.

Example (client app):

using ModularSystem.Core;
using ModularSystem.Web;
using MyApp;

namespace MyClientApp;

public class Program
{
    public static async Task Main()
    {
        var config = new EndpointConfiguration("https://localhost:5001/api/user");
        var userClient = new CrudClient<User>(config);
        
        var query = new SerializedQueryFactory<User>()
            .SetFilter(user => user.Email == "foo@bar.baz")
            .Create();
            
        var queryResult = await userClient.QueryAsync(query);
    }
}

WORK IN PROGRESS...

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ModularSystem.Core:

Package Downloads
PlataformaOmega.IntegrationLibrary

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.40.0-prerelease.8 102 1/10/2024
1.40.0-prerelease.7 120 11/14/2023
1.40.0-prerelease.6 71 11/2/2023
1.40.0-prerelease.5 64 10/20/2023
1.40.0-prerelease.4 56 10/16/2023
1.40.0-prerelease.3 57 10/16/2023
1.40.0-prerelease.2 58 10/16/2023
1.40.0-prerelease.1 58 10/15/2023
1.39.1 158 9/28/2023
1.39.0 108 9/28/2023
1.38.2 106 9/27/2023
1.38.1 113 9/25/2023
1.38.0 118 9/19/2023
1.37.3 112 9/18/2023
1.37.2 82 9/18/2023
1.37.1 101 9/18/2023
1.37.0 132 9/13/2023
1.36.0 132 9/12/2023
1.35.6 121 9/12/2023
1.35.5 120 9/12/2023
1.35.4 130 9/11/2023
1.35.3 122 9/7/2023
1.35.2 105 9/6/2023
1.35.1 129 9/6/2023
1.35.0 128 9/6/2023
1.35.0-prerelease.42 77 8/31/2023
1.35.0-prerelease.41 67 8/31/2023
1.35.0-prerelease.40 80 8/30/2023
1.35.0-prerelease.39 71 8/30/2023
1.35.0-prerelease.38 79 8/29/2023
1.35.0-prerelease.37 78 8/27/2023
1.35.0-prerelease.36 72 8/26/2023
1.35.0-prerelease.35 66 8/26/2023
1.35.0-prerelease.34 70 8/26/2023
1.35.0-prerelease.33 63 8/26/2023
1.35.0-prerelease.32 70 8/25/2023
1.35.0-prerelease.31 80 8/25/2023
1.35.0-prerelease.30 65 8/25/2023
1.35.0-prerelease.29 71 8/25/2023
1.35.0-prerelease.28 70 8/25/2023
1.35.0-prerelease.27 65 8/25/2023
1.35.0-prerelease.26 68 8/25/2023
1.35.0-prerelease.25 66 8/25/2023
1.35.0-prerelease.24 71 8/25/2023
1.35.0-prerelease.23 74 8/24/2023
1.35.0-prerelease.22 71 8/24/2023
1.35.0-prerelease.21 71 8/23/2023
1.35.0-prerelease.20 66 8/23/2023
1.35.0-prerelease.19 65 8/23/2023
1.35.0-prerelease.18 74 8/19/2023
1.35.0-prerelease.17 66 8/19/2023
1.35.0-prerelease.16 73 8/19/2023
1.35.0-prerelease.15 67 8/18/2023
1.35.0-prerelease.14 72 8/16/2023
1.35.0-prerelease.13 71 8/16/2023
1.35.0-prerelease.12 74 8/15/2023
1.35.0-prerelease.11 81 8/14/2023
1.35.0-prerelease.10 81 8/13/2023
1.35.0-prerelease.9 76 8/13/2023
1.35.0-prerelease.8 86 8/9/2023
1.35.0-prerelease.7 87 8/2/2023
1.35.0-prerelease.6 84 8/2/2023
1.35.0-prerelease.5 84 8/2/2023
1.35.0-prerelease.4 71 8/2/2023
1.35.0-prerelease.2 110 8/1/2023
1.35.0-prerelease.1 89 7/25/2023
1.34.3 156 7/14/2023
1.34.2 170 7/11/2023
1.34.1 151 7/11/2023
1.34.0 119 7/11/2023
1.33.1 148 7/6/2023
1.33.0 154 7/6/2023
1.32.7 159 5/31/2023
1.32.6 204 5/31/2023
1.32.5 153 5/31/2023
1.32.4 148 5/31/2023
1.32.3 157 5/30/2023
1.32.2 198 5/30/2023
1.32.1 193 5/30/2023
1.32.0 141 5/26/2023
1.31.6 178 4/25/2023
1.31.5 176 4/25/2023
1.31.4 248 4/24/2023
1.31.3 187 4/21/2023
1.31.2 161 4/20/2023
1.31.1 112 4/14/2023
1.31.0 164 4/6/2023
1.30.0 110 4/4/2023
1.29.18 400 3/18/2023
1.29.17 305 3/18/2023
1.29.16 239 3/16/2023
1.29.15 239 3/16/2023
1.29.14 229 3/14/2023
1.29.13 491 3/9/2023
1.29.12 477 3/6/2023
1.29.11 248 3/3/2023
1.29.10 233 3/3/2023
1.29.9 324 3/2/2023
1.29.8 320 3/2/2023
1.29.7 565 3/1/2023
1.29.6 240 3/1/2023
1.29.5 318 2/27/2023
1.29.4 244 2/27/2023
1.29.3 256 2/25/2023
1.29.2 264 2/24/2023
1.29.1 276 2/24/2023
1.29.0 259 2/24/2023
1.28.4 243 2/22/2023
1.28.3 335 2/18/2023
1.28.2 258 2/18/2023
1.28.1 269 2/17/2023
1.28.0 406 2/16/2023
1.27.0 273 2/8/2023
1.26.3 270 2/7/2023
1.26.2 274 2/7/2023
1.26.1 270 2/7/2023
1.26.0 276 2/6/2023
1.25.21 279 2/4/2023
1.25.20 381 2/4/2023
1.25.19 281 2/4/2023
1.25.18 272 2/4/2023
1.25.17 264 2/3/2023
1.25.16 295 2/3/2023
1.25.15 273 1/28/2023
1.25.14 280 1/28/2023
1.25.13 299 1/27/2023
1.25.12 309 1/27/2023
1.25.11 436 1/27/2023
1.25.10 299 1/27/2023
1.25.9 383 1/20/2023
1.25.8 316 1/20/2023
1.25.7 314 1/20/2023
1.25.6 327 1/20/2023
1.25.5 303 1/20/2023
1.25.4 374 1/20/2023
1.25.3 317 1/20/2023
1.25.2 302 1/20/2023
1.25.1 305 1/19/2023
1.25.0 326 1/19/2023
1.24.4 528 1/13/2023
1.24.3 333 1/13/2023
1.24.2 311 1/13/2023
1.24.1 331 1/13/2023
1.24.0 318 1/13/2023
1.23.0 574 9/14/2022
1.22.0 470 8/27/2022
1.21.0 469 8/16/2022
1.20.1 488 8/4/2022
1.20.0 601 7/23/2022
1.19.3 512 7/8/2022
1.19.2 509 7/8/2022
1.19.1 911 7/7/2022
1.19.0 483 7/7/2022
1.18.10 629 7/6/2022
1.18.9 904 7/2/2022
1.18.8 483 7/2/2022
1.18.7 512 7/2/2022
1.18.6 507 7/2/2022
1.18.5 498 7/2/2022
1.18.4 487 7/2/2022
1.18.3 483 7/1/2022
1.18.2 506 6/28/2022
1.18.1 533 6/28/2022
1.18.0 479 6/27/2022
1.17.0 505 6/27/2022
1.16.8 535 5/16/2022
1.16.7 530 5/12/2022
1.16.6 543 5/10/2022
1.16.5 559 5/10/2022
1.16.4 529 5/10/2022
1.16.3 527 5/10/2022
1.16.2 553 4/30/2022
1.16.1 540 4/30/2022
1.16.0 538 4/30/2022
1.15.2 562 4/28/2022
1.15.1 533 4/27/2022
1.15.0 1,451 4/27/2022
1.14.8 553 4/1/2022
1.14.7 564 4/1/2022
1.14.6 564 4/1/2022
1.14.5 541 4/1/2022
1.14.4 583 3/27/2022
1.14.3 552 3/26/2022
1.14.2 559 3/25/2022
1.14.1 965 3/23/2022
1.14.0 534 3/23/2022
1.13.1 571 3/22/2022
1.13.0 547 3/22/2022
1.12.2 545 3/22/2022
1.12.1 730 3/22/2022
1.12.0 543 3/22/2022
1.11.2 575 3/11/2022
1.11.1 568 3/10/2022
1.11.0 548 3/10/2022
1.10.0 697 3/7/2022
1.9.2 592 3/3/2022
1.9.1 567 3/3/2022
1.9.0 1,625 2/26/2022
1.8.3 557 2/26/2022
1.8.2 574 2/1/2022
1.8.1 583 1/24/2022
1.8.0 586 1/24/2022
1.7.1 628 1/19/2022
1.7.0 589 1/19/2022
1.6.0 585 1/19/2022
1.5.0 602 1/19/2022
1.4.3 482 1/14/2022
1.4.2 496 1/14/2022
1.4.1 606 1/13/2022
1.4.0 487 1/13/2022
1.3.0 625 1/12/2022
1.2.0 485 1/11/2022
1.1.3 496 1/11/2022
1.1.2 475 1/11/2022
1.1.1 490 1/11/2022
1.1.0 487 1/11/2022

JobQueue fix.