{"id":17336308,"url":"https://github.com/alsami/mediatr.extensions.autofac.dependencyinjection","last_synced_at":"2025-05-16T13:04:31.471Z","repository":{"id":49381718,"uuid":"140109076","full_name":"alsami/MediatR.Extensions.Autofac.DependencyInjection","owner":"alsami","description":"Autofac plug-in for MediatR.","archived":false,"fork":false,"pushed_at":"2025-02-20T08:24:48.000Z","size":512,"stargazers_count":56,"open_issues_count":1,"forks_count":14,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T07:43:31.864Z","etag":null,"topics":["autofac","cqrs","dependencyinjection","ioc-container","mediator-pattern","mediatr","nuget"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alsami.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-07T18:42:24.000Z","updated_at":"2025-03-04T13:09:34.000Z","dependencies_parsed_at":"2024-10-31T14:03:51.974Z","dependency_job_id":"02f7c326-321d-46c7-b308-ad4b575cb32a","html_url":"https://github.com/alsami/MediatR.Extensions.Autofac.DependencyInjection","commit_stats":{"total_commits":96,"total_committers":4,"mean_commits":24.0,"dds":0.05208333333333337,"last_synced_commit":"81a3c93c6e0af509898bcbf1a8c533256be7d09f"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FMediatR.Extensions.Autofac.DependencyInjection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FMediatR.Extensions.Autofac.DependencyInjection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FMediatR.Extensions.Autofac.DependencyInjection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FMediatR.Extensions.Autofac.DependencyInjection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alsami","download_url":"https://codeload.github.com/alsami/MediatR.Extensions.Autofac.DependencyInjection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535826,"owners_count":22087398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autofac","cqrs","dependencyinjection","ioc-container","mediator-pattern","mediatr","nuget"],"created_at":"2024-10-15T15:29:14.880Z","updated_at":"2025-05-16T13:04:31.436Z","avatar_url":"https://github.com/alsami.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MediatR.Extensions.Autofac.DependencyInjection\n\n[![Build Application](https://github.com/alsami/MediatR.Extensions.Autofac.DependencyInjection/actions/workflows/push.yml/badge.svg?branch=main\u0026event=push)](https://github.com/alsami/MediatR.Extensions.Autofac.DependencyInjection/actions/workflows/push.yml)\n[![codecov](https://codecov.io/gh/alsami/MediatR.Extensions.Autofac.DependencyInjection/branch/master/graph/badge.svg)](https://codecov.io/gh/alsami/MediatR.Extensions.Autofac.DependencyInjection)\n\n[![NuGet](https://img.shields.io/nuget/vpre/MediatR.Extensions.Autofac.DependencyInjection.svg)](https://www.nuget.org/packages/MediatR.Extensions.Autofac.DependencyInjection)\n![Nuget](https://img.shields.io/nuget/dt/MediatR.Extensions.Autofac.DependencyInjection)\n\nThis is a cross platform library, supporting .NET standard 2.0, that serves as an extension for [Autofac's containerbuilder](https://autofac.org/).\nIt will register all necessary classes and interfaces of Jimmy Bogard's [MediatR](https://github.com/jbogard/MediatR) implementation to the autofac-container \nso you can use cqrs and the [mediator pattern](https://sourcemaking.com/design_patterns/mediator) right ahread without worrying about setting up required infrastracture code.\n\n## Installation\n\nThis package is available via nuget. You can install it using Visual-Studio-Nuget-Browser or by using the dotnet-cli\n\n```\ndotnet add package MediatR.Extensions.Autofac.DependencyInjection\n```\n\nIf you want to add a specific version of this package\n\n```\ndotnet add package MediatR.Extensions.Autofac.DependencyInjection --version 1.0.0\n```\n\nFor more information please visit the official [dotnet-cli documentation](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-add-package).\n\n## Usage\n\nAfter you have successfully installed the package go ahead to your class and use the extension.\n\n```c#\npublic class Pong \n{\n    public DateTime ResponseSendAt { get; }\n    \n    public Pong(responseSendAt)\n    {\n        this.ResponseSendAt = responseSendAt;\n    }\n}\n\npublic class PingCommand : IRequest\u003cPong\u003e {} // Command\n\npublic class PingCommandHandler : IRequestHandler\u003cPingCommand, Pong\u003e\n{\n    public async Task Handle(PingCommand request, CancellationToken cancellationToken) \n    {\n        return await Task.FromResult(new Pong(DateTime.UtcNow)).ConfigureAwait(false);\n    } \n}\n\npublic class Program \n{\n    public async Task Main(string[] args)\n    {\n        var builder = new ContainerBuilder();\n\n        var configuration = MediatRConfigurationBuilder\n            .Create(typeof(ResponseCommand).Assembly)\n            .WithAllOpenGenericHandlerTypesRegistered()\n            .Build();\n\n        // this will add all your Request- and Notificationhandler\n        // that are located in the same project as your program-class\n        builder.RegisterMediatR(configuration);\n        \n        var container = builder.Build();\n        \n        var mediator = container.Resolve\u003cIMediator\u003e();\n        \n        var response = await mediator.Send(new PingCommand());\n        \n        // more code here\n    }\n}\n```\n\nBy default all `MediatR` dependencies will be registered as transient (`InstancePerDependency`). Starting with version `9.2.0` you can configure the scope\n\n```csharp\nvar builder = new ContainerBuilder();\n\nvar configuration = MediatRConfigurationBuilder\n    .Create(typeof(ResponseCommand).Assembly)\n    .WithAllOpenGenericHandlerTypesRegistered()\n    .WithRegistrationScope(RegistrationScope.Scoped) // currently only supported values are `Transient` and `Scoped`\n    .Build();\n\nbuilder.RegisterMediatR(configuration);\n```\n\nFor more information about the usage please check out the [samples](https://github.com/alsami/MediatR.Extensions.Autofac.DependencyInjection/tree/main/samples) and [tests](https://github.com/alsami/MediatR.Extensions.Autofac.DependencyInjection/tree/main/test) of the solution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsami%2Fmediatr.extensions.autofac.dependencyinjection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falsami%2Fmediatr.extensions.autofac.dependencyinjection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsami%2Fmediatr.extensions.autofac.dependencyinjection/lists"}