elideus-dot-net-framework-core
2.1.0
dotnet add package elideus-dot-net-framework-core --version 2.1.0
NuGet\Install-Package elideus-dot-net-framework-core -Version 2.1.0
<PackageReference Include="elideus-dot-net-framework-core" Version="2.1.0" />
<PackageVersion Include="elideus-dot-net-framework-core" Version="2.1.0" />
<PackageReference Include="elideus-dot-net-framework-core" />
paket add elideus-dot-net-framework-core --version 2.1.0
#r "nuget: elideus-dot-net-framework-core, 2.1.0"
#addin nuget:?package=elideus-dot-net-framework-core&version=2.1.0
#tool nuget:?package=elideus-dot-net-framework-core&version=2.1.0
Elideus | DotNet Framework Core
Core is a subpackage of the Elideus-DotNet-Framework, providing the fundamental features for building an application.
To configure an application to use this package, you need to create an ApplicationClass
that inherits from ElideusDotNetFrameworkApplication
:
public class MyApp : ElideusDotNetFrameworkApplication {
}
In the Program.cs
file, you can replace all existing code with:
class Program
{
static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
var app = new AppClass();
app.InitializeApp(builder);
}
}
At this point, the application is ready to run, but without any actual logic or endpoints configured.
Dependencies
In this framework, dependencies are injected into an ApplicationContext
within the application class.
In the MyApp
class we just created, you can override a method called InjectDependencies
. In that method, you can use a property inherited from ElideusDotNetFrameworkApplication
to inject dependencies into the application context.
Example:
protected override void InjectDependencies(ref WebApplicationBuilder builder)
{
base.InjectDependencies(ref builder);
ApplicationContext?.AddDependency<IMyDatabaseProvider, MyDatabaseProvider>(ref builder);
}
All injected dependencies will then be available anywhere the ApplicationContext
is accessible.
Mapping
The Core package includes AutoMapper by default, exposing a dependency called IMapperProvider
. This can be used to perform mapping operations and configure mapper profiles.
To configure mapper profiles, you can override the InitializeAutoMapper
method in the MyApp
class and add all necessary profiles:
protected override void InitializeAutoMapper()
{
base.InitializeAutoMapper();
var mapper = ApplicationContext.GetDependency<IMapperProvider>();
mapper.CreateMapper(
new List<AutoMapper.Profile>
{
new MyMapperProfileForThis(),
new MyMapperProfileForThat(),
});
}
To perform a mapping between types:
var mapperProvider = executionContext.GetDependency<IMapperProvider>();
var mappedResult = mapperProvider.Map<Type1, Type2>(objectToMap);
Operations
To expose endpoints, you must create an operation. An operation defines the logic behind a specific endpoint.
Let�s say we want to create an operation to retrieve a list of users.
First, define the input and output classes.
The input must inherit from OperationInput
to be recognized by the framework:
public class MyOperationInput : OperationInput
{
}
In this case, since we don�t need any parameters, we can use the built-in VoidOperationInput
.
Similarly, the output must inherit from OperationOutput
, which provides basic response structure:
public class GetUsersOutput : OperationOutput
{
public List<User> users { get; set; }
}
Now, create the GetUsersOperation
that inherits from BaseOperation
.
There are a few requirements when inheriting from the base operation. The constructor must receive the ApplicationContext
and the endpoint path. Also, you must specify the input and output types:
public class GetUsersOperation(IApplicationContext context, string endpoint): BaseOperation<VoidOperationInput, GetUsersOutput>
{
}
An operation can override three main methods:
InitAsync
Executed as soon as the operation is called. Useful for retrieving dependencies:
protected override async Task InitAsync()
{
await base.InitAsync();
mapperProvider = executionContext.GetDependency<IMapperProvider>()!;
}
ValidateInput
Used to validate the input and return an error if invalid:
protected override async Task<(HttpStatusCode? StatusCode, Error? Error)> ValidateInput(HttpRequest request, VoidOperationInput input)
{
// Custom validation
}
ExecuteAsync
The main operation logic. Returns the output object:
protected override async Task<GetUsersOutput> ExecuteAsync(VoidOperationInput input)
{
// Operation logic
return new GetUsersOutput
{
// Data
};
}
Operations Builder
Once the operation is created, it needs to be mapped.
Operations are mapped using a class that inherits from OperationsBuilder
:
public class MyOperationsBuilder : OperationsBuilder
{
}
To tell the application which operations builder to use, override the OperationsBuilder
property in your MyApp
class:
protected override OperationsBuilder OperationsBuilder { get; set; } = new MyOperationsBuilder();
Inside your builder class, override the MapOperations
method. Use MapPostOperation
to define each operation mapping.
This method requires the operation type, input and output types, and instances of the app, context, and operation.
Example:
public override void MapOperations(ref WebApplication app, IApplicationContext context)
{
MapPostOperation<GetUsersOperation, VoidOperationInput, GetUsersOutput>(ref app, context, new GetUsersOperation(context, "/GetUsers"));
}
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
- AutoMapper (>= 14.0.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.12)
- Microsoft.AspNetCore.Http (>= 2.3.0)
- Microsoft.Extensions.Logging (>= 9.0.3)
- Newtonsoft.Json (>= 13.0.3)
- Swashbuckle.AspNetCore (>= 6.4.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on elideus-dot-net-framework-core:
Package | Downloads |
---|---|
elideus-dot-net-framework-external-services
Package Description |
|
elideus-dot-net-framework-tests
Package Description |
|
elideus-dot-net-banking-authentication-tier-contracts
Package Description |
|
elideus-dot-net-framework-database
Package Description |
|
elideus-dot-net-banking-data-tier-contracts
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.0 | 204 | 4/10/2025 |