Gestalt.Console
1.0.11
See the version list below for details.
dotnet add package Gestalt.Console --version 1.0.11
NuGet\Install-Package Gestalt.Console -Version 1.0.11
<PackageReference Include="Gestalt.Console" Version="1.0.11" />
paket add Gestalt.Console --version 1.0.11
#r "nuget: Gestalt.Console, 1.0.11"
// Install Gestalt.Console as a Cake Addin #addin nuget:?package=Gestalt.Console&version=1.0.11 // Install Gestalt.Console as a Cake Tool #tool nuget:?package=Gestalt.Console&version=1.0.11
<img src="https://jacraig.github.io/Gestalt/images/Icon.png" style="height:25px" alt="Gestalt Icon" /> Gestalt
Gestalt is a C# library designed to facilitate the development of modular applications. It allows developers to create reusable modules that can be easily integrated into various applications, enhancing code reusability and maintainability.
Table of Contents
Introduction
Modern software development often requires building applications with modular architectures to promote reusability and scalability. Gestalt provides a framework for organizing application functionality into cohesive modules, encapsulating logic and services that can be easily shared across different projects.
Features
- Modular Architecture: Define modules encapsulating configuration, services, and lifecycle events.
- Configuration Management: Easily configure application settings using built-in configuration providers.
- Dependency Injection: Utilize dependency injection for managing dependencies and services.
- Lifecycle Management: Implement lifecycle events such as application start, stop, and shutdown.
Getting Started
Installation
Gestalt can be installed via NuGet Package Manager:
dotnet add package Gestalt.Core
Or for framework specific functionality, install the appropriate package:
# For ASP.NET base functionality
dotnet add package Gestalt.AspNet
# For ASP.NET MVC functionality
dotnet add package Gestalt.AspNet.MVC
# For ASP.NET Controllers functionality (without views)
dotnet add package Gestalt.AspNet.Controllers
# For ASP.NET SignalR functionality
dotnet add package Gestalt.AspNet.SignalR
# For ASP.NET Razor Pages functionality
dotnet add package Gestalt.AspNet.RazorPages
# For console applications
dotnet add package Gestalt.Console
Creating Modules
To create a module, follow these steps:
Define a class that inherits from one of the *ModuleBaseClasses or implements one of the IApplicationModule interfaces (IMvcModule, ISignalRModule, IRazorPagesModule, etc).
Override methods for configuring settings, services, and lifecycle events.
Implement module-specific functionality within the class.
A basic example of a module class is shown below:
/// <summary>
/// This is an example of a basic module that configures the application with the usual default settings when creating a new web application.
/// It implements the MvcModuleBaseClass which simplifies the process of creating a module that needs to modify MVC settings.
/// However, you can implement the IMvcModule interface directly if you prefer.
/// </summary>
public class BasicModule : MvcModuleBaseClass<BasicModule>
{
/// <summary>
/// This is called to configure the IApplicationBuilder object. Since this is an MVC app, that would be the WebApplication object.
/// </summary>
/// <param name="applicationBuilder">The application builder object.</param>
/// <param name="configuration">The configuration object.</param>
/// <param name="environment">The host environment object.</param>
/// <returns>The application builder object should be returned.</returns>
public override IApplicationBuilder? ConfigureApplication(IApplicationBuilder? applicationBuilder, IConfiguration? configuration, IHostEnvironment? environment)
{
if (applicationBuilder is null)
return applicationBuilder;
// Configure the HTTP request pipeline.
if (environment?.IsDevelopment() == false)
{
// This is the default exception handler for the application when in production.
_ = applicationBuilder.UseExceptionHandler("/Home/Error");
// We will add a strict transport security header to the response.
_ = applicationBuilder.UseHsts();
}
// This will redirect HTTP requests to HTTPS.
_ = applicationBuilder.UseHttpsRedirection();
// And let's serve static files.
_ = applicationBuilder.UseStaticFiles();
// We will also add authorization to the application.
_ = applicationBuilder.UseAuthorization();
// And lastly, we will return the application builder.
return applicationBuilder;
}
/// <summary>
/// This is called to configure the MVC options. We will just return the options object as is.
/// </summary>
/// <param name="mVCBuilder">The MVC builder object.</param>
/// <param name="configuration">The configuration object.</param>
/// <param name="environment">The host environment object.</param>
/// <returns>The MVC builder object.</returns>
public override IMvcBuilder? ConfigureMVC(IMvcBuilder? mVCBuilder, IConfiguration? configuration, IHostEnvironment? environment)
{
return mVCBuilder;
}
/// <summary>
/// This is called to configure our endpoint routes. For our example, we will just use the default route.
/// </summary>
/// <param name="endpoints">The endpoint route builder.</param>
/// <param name="configuration">The configuration object.</param>
/// <param name="environment">The host environment object.</param>
/// <returns>The endpoint route builder.</returns>
public override IEndpointRouteBuilder? ConfigureRoutes(IEndpointRouteBuilder? endpoints, IConfiguration? configuration, IHostEnvironment? environment)
{
if (endpoints is null)
return endpoints;
// Map the default route.
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
return endpoints;
}
}
Using Modules
To have your application start using modules, you just need to call UseGestalt on the application builder:
// Program.cs
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
var app = builder.UseGestalt<ExampleModule>();
app.Run();
}
}
For more advanced usage, refer to the documentation.
Contributing
Contributions to Gestalt are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request. Before contributing, please review the contribution guidelines.
License
Gestalt is licensed under the Apache 2.0 License.
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 is compatible. 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
- Gestalt.Core (>= 1.0.11)
- Microsoft.Extensions.Hosting (>= 8.0.0)
-
net8.0
- Gestalt.Core (>= 1.0.11)
- Microsoft.Extensions.Hosting (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.39 | 0 | 11/4/2024 |
1.0.38 | 50 | 10/31/2024 |
1.0.37 | 60 | 10/29/2024 |
1.0.36 | 67 | 10/29/2024 |
1.0.35 | 76 | 10/10/2024 |
1.0.34 | 78 | 10/9/2024 |
1.0.33 | 81 | 10/8/2024 |
1.0.32 | 98 | 8/28/2024 |
1.0.31 | 98 | 8/26/2024 |
1.0.30 | 108 | 8/23/2024 |
1.0.29 | 121 | 8/21/2024 |
1.0.28 | 126 | 8/15/2024 |
1.0.27 | 69 | 8/3/2024 |
1.0.26 | 82 | 7/24/2024 |
1.0.25 | 93 | 7/10/2024 |
1.0.24 | 95 | 6/26/2024 |
1.0.23 | 94 | 6/25/2024 |
1.0.22 | 118 | 6/18/2024 |
1.0.21 | 107 | 6/18/2024 |
1.0.20 | 109 | 6/14/2024 |
1.0.19 | 94 | 6/12/2024 |
1.0.18 | 91 | 5/30/2024 |
1.0.17 | 103 | 5/30/2024 |
1.0.16 | 102 | 5/17/2024 |
1.0.15 | 102 | 5/16/2024 |
1.0.14 | 106 | 5/7/2024 |
1.0.13 | 123 | 5/6/2024 |
1.0.12 | 70 | 5/2/2024 |
1.0.11 | 92 | 5/1/2024 |
1.0.10 | 100 | 5/1/2024 |
1.0.9 | 118 | 4/29/2024 |
1.0.8 | 105 | 4/12/2024 |
1.0.7 | 114 | 4/11/2024 |
1.0.6 | 120 | 3/30/2024 |
1.0.5 | 119 | 3/28/2024 |
1.0.4 | 110 | 3/26/2024 |
1.0.3 | 114 | 3/26/2024 |
1.0.2 | 100 | 3/26/2024 |
1.0.1 | 118 | 3/22/2024 |