Raain.Core 1.0.72

dotnet add package Raain.Core --version 1.0.72
                    
NuGet\Install-Package Raain.Core -Version 1.0.72
                    
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="Raain.Core" Version="1.0.72" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Raain.Core" Version="1.0.72" />
                    
Directory.Packages.props
<PackageReference Include="Raain.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Raain.Core --version 1.0.72
                    
#r "nuget: Raain.Core, 1.0.72"
                    
#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.
#:package Raain.Core@1.0.72
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Raain.Core&version=1.0.72
                    
Install as a Cake Addin
#tool nuget:?package=Raain.Core&version=1.0.72
                    
Install as a Cake Tool

Raain.Core

Raain.Core is a shared .NET class library providing core functionalities including CORS, Extensions, Exception Handling, Firebase, SignalR, caching, and more.


Features

  • Centralized extensions and helpers for .NET projects
  • JWT authentication helpers
  • Firebase integration
  • SignalR helper methods
  • CORS and API versioning support
  • Health checks for PostgreSQL and Redis
  • Logging using Serilog
  • Compatible with .NET 8.0 (multi-targeting possible)

Getting Started

Prerequisites

  • .NET SDK 8.0+ installed
  • NuGet 6.0+ (comes with .NET SDK)
  • Optional: PostgreSQL and Redis if using health checks

Example Usage

Configuring App Constants (RaainCoreConstOptions)

Your application can override default constants provided by the Raain.Core package at runtime.

1. Override Specific Values

Use RaainCoreConst.Configure to override only the properties you need:

using Raain.Core.Shared.Consts;

// Override some defaults in Program.cs
RaainCoreConst.Configure(opts =>
{
    opts.AppName = "My Custom App";
    opts.DefaultUsername = "customadmin@myapp.com";
    opts.SwaggerApi = "My API";
    opts.ApiKeyHeader = "X-My-Api-Key";
});
  • Only the values you set will be replaced; all other defaults remain intact.
  • Safe to call multiple times in different modules or initialization code.

2. Replace the Entire Options Object

You can create a full custom AppConstOptions instance and replace the defaults entirely:

var customOptions = new RaainCoreConstOptions
{
    AppName = "Entirely New App",
    DefaultUsername = "admin@newapp.com",
    SwaggerApi = "New Swagger API",
    CorsPolicyName = "CustomPolicy",
    DefaultOrganizationMetadata = new JsonObject
    {
        ["custom_key"] = "custom value"
    }
};

// In Program.cs
RaainCoreConst.SetOptions(customOptions);

Or with class:

public class AppConst: RaainCoreConstOptions
{
    // =======================
    // App & System Defaults
    // =======================
    public override string AppName { get; set; } = "RAAIN";
    ... Other options

// In Program.cs
RaainCoreConst.SetOptions(new AppConst());
  • This approach replaces all defaults, so make sure to set all required properties.
  • Useful if you want to inject completely different defaults from your app configuration.

3. Accessing Configured Values

Anywhere in your application, you can read the configured values:

string appName = RaainCoreConst.Options.AppName;
string apiHeader = RaainCoreConst.Options.ApiKeyHeader;
string defaultUser = RaainCoreConst.Options.DefaultUsername;
JsonObject metadata = RaainCoreConst.Options.DefaultOrganizationMetadata;

Dependencies Setup

Raain.Core provides a consistent pattern to register services and middlewares across your application. The convention is:

  • Dependency Injection (services): Add[Package][Feature]()
  • Middleware / pipeline configuration: Use[Package][Feature]()

Below is a summary of common modules and how to set them up.

Authentication & Authorization

// In ConfigureServices
services.AddRaainAuth(Configuration);

// In Configure / middleware pipeline
app.UseRaainAuth();

Session Management

services.AddRaainSession(Configuration);
app.UseRaainSession();

Data Access (Database / Repositories)

services.AddRaainDataAccess(Configuration);

Swagger / OpenAPI

services.AddRaainSwagger();
app.UseRaainSwagger();

Raain Notify (SignalR Notification)

// Configure AppConst options globally
AppConst.Configure(opts =>
{
    opts.RaainNotifyHubPath = "/custom-notify";
    opts.RaainNotifyNotifyAllHook = "CustomNotifyAll";
});

// Add Notify
builder.Services.AddRaainNotifyHub();

// Map hub if enabled
app.UseRaainNotifyHub(builder.Configuration);
  • Sending notifications from server code:
using Microsoft.AspNetCore.SignalR;
using Raain.Core.RaainNotify;

public class NotificationService
{
    private readonly IHubContext<RaainNotifyHub> _hub;

    public NotificationService(IHubContext<RaainNotifyHub> hub)
    {
        _hub = hub;
    }

    public async Task NotifyEveryoneAsync(string message)
    {
        // Notify all clients
        await _hub.Clients.All.SendAsync(AppConst.Options.RaainNotifyNotifyAllHook, message);
    }

    public async Task NotifyUserAsync(string userId, string message, ICachingService cache)
    {
        var key = CacheKey.Create(CacheGroupEnum.NotificationHub, userId);
        var connections = await cache.GetRedisCacheAsync<HashSet<string>>(key);
        if (connections != null)
        {
            foreach (var connId in connections)
                await _hub.Clients.Client(connId).SendAsync(AppConst.Options.RaainNotifyNotifyAllHook, message);
        }
    }
}

Health Checks

services.AddRaainHealthChecks();

app.UseRaainHealthChecks();

 // Or if not overriden RaainAppConstOptions.HealthCheckPath
 app.UseRaainHealthCheck("/custom-health");

JSON Utilities / Serialization

services.AddRaainJson();

CORS policy

services.AddRaainCors();
services.UseRaainCors();

Rate Limit

services.AddRaainRateLimit();
services.UseRaainRateLimit();

Request Logging

services.AddRaainRequestLogging();
services.UseRaainRequestLogging();
Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.72 113 4/4/2026
Loading failed