SkillAgentSearch skills...

NRules.Integration.AspNetCore

No description available

Install / Use

/learn @cloudb0x/NRules.Integration.AspNetCore
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

NRules.Integration.AspNetCore

Build Status Nuget

An Integration For Nrules for Asp .Net Core for the built in Dependency Injection container.

Getting Started

Adding the integration is as straightforward as calling two extension methods in your Startup.cs class.

Startup.cs

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddNRules(AppDomain.CurrentDomain.GetAssemblies()) // Loads Rules from assemblies and Registers NRule with DI Container
                .AddMvc();
    }
    
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }
        app.UseNRules(); //Add the configured DI Container as the dependency resolver for Nrules
        app.UseHttpsRedirection();
        app.UseMvc();
    }

Usage

Simply Injecting ISession into your dependency is enough. This Calls the ISessionFactory and creates a new scoped session.

public class SomeService : ISomeService
{
    private readonly ISession _session;

    public SomeService(ISession session)
    {
        _session = session;
    }

    public void DoSomethingWithSession()
    {
        var fact = "I Am a Fact";

        _session.Insert(fact);

        _session.Fire();

    }
}

Related Skills

View on GitHub
GitHub Stars10
CategoryDevelopment
Updated2y ago
Forks2

Languages

C#

Security Score

75/100

Audited on Jul 20, 2023

No findings