{"id":13415193,"url":"https://github.com/jbogard/MediatR","last_synced_at":"2025-03-14T22:33:02.232Z","repository":{"id":14651280,"uuid":"17369361","full_name":"jbogard/MediatR","owner":"jbogard","description":"Simple, unambitious mediator implementation in .NET","archived":false,"fork":false,"pushed_at":"2024-09-11T18:39:03.000Z","size":5974,"stargazers_count":11084,"open_issues_count":13,"forks_count":1173,"subscribers_count":291,"default_branch":"master","last_synced_at":"2024-10-16T13:05:40.223Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbogard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2014-03-03T15:01:22.000Z","updated_at":"2024-10-16T09:21:07.000Z","dependencies_parsed_at":"2023-01-16T20:01:15.287Z","dependency_job_id":"6d3fb3f3-c93c-44e5-a8b2-eacc4b56136f","html_url":"https://github.com/jbogard/MediatR","commit_stats":{"total_commits":457,"total_committers":86,"mean_commits":5.313953488372093,"dds":0.4595185995623632,"last_synced_commit":"b3147c8afada633ae0f77146c081ba4a6f949b37"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbogard%2FMediatR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbogard%2FMediatR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbogard%2FMediatR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbogard%2FMediatR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbogard","download_url":"https://codeload.github.com/jbogard/MediatR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221513999,"owners_count":16835757,"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":["hacktoberfest"],"created_at":"2024-07-30T21:00:44.809Z","updated_at":"2024-10-26T08:31:25.212Z","avatar_url":"https://github.com/jbogard.png","language":"C#","funding_links":[],"categories":["Frameworks, Libraries and Tools","Event aggregator and messenger","时间聚合器和发送器","C\\#","C#","hacktoberfest","Quasi Awesome Learning path","C# #","框架, 库和工具","Mediator Pattern","Libraries","其他","Libraries and Frameworks","Misc","🗒️ Cheatsheets"],"sub_categories":["Queue and Messaging","消息队列","Messaging and Queue","网络服务_其他",".NET","📦 Libraries"],"readme":"MediatR\n=======\n\n![CI](https://github.com/jbogard/MediatR/workflows/CI/badge.svg)\n[![NuGet](https://img.shields.io/nuget/dt/mediatr.svg)](https://www.nuget.org/packages/mediatr) \n[![NuGet](https://img.shields.io/nuget/vpre/mediatr.svg)](https://www.nuget.org/packages/mediatr)\n[![MyGet (dev)](https://img.shields.io/myget/mediatr-ci/v/MediatR.svg)](https://myget.org/gallery/mediatr-ci)\n\nSimple mediator implementation in .NET\n\nIn-process messaging with no dependencies.\n\nSupports request/response, commands, queries, notifications and events, synchronous and async with intelligent dispatching via C# generic variance.\n\nExamples in the [wiki](https://github.com/jbogard/MediatR/wiki).\n\n### Installing MediatR\n\nYou should install [MediatR with NuGet](https://www.nuget.org/packages/MediatR):\n\n    Install-Package MediatR\n    \nOr via the .NET Core command line interface:\n\n    dotnet add package MediatR\n\nEither commands, from Package Manager Console or .NET Core CLI, will download and install MediatR and all required dependencies.\n\n### Using Contracts-Only Package\n\nTo reference only the contracts for MediatR, which includes:\n\n- `IRequest` (including generic variants)\n- `INotification`\n- `IStreamRequest`\n\nAdd a package reference to [MediatR.Contracts](https://www.nuget.org/packages/MediatR.Contracts)\n\nThis package is useful in scenarios where your MediatR contracts are in a separate assembly/project from handlers. Example scenarios include:\n- API contracts\n- GRPC contracts\n- Blazor\n\n### Registering with `IServiceCollection`\n\nMediatR supports `Microsoft.Extensions.DependencyInjection.Abstractions` directly. To register various MediatR services and handlers:\n\n```\nservices.AddMediatR(cfg =\u003e cfg.RegisterServicesFromAssemblyContaining\u003cStartup\u003e());\n```\n\nor with an assembly:\n\n```\nservices.AddMediatR(cfg =\u003e cfg.RegisterServicesFromAssembly(typeof(Startup).Assembly));\n```\n\nThis registers:\n\n- `IMediator` as transient\n- `ISender` as transient\n- `IPublisher` as transient\n- `IRequestHandler\u003c,\u003e` concrete implementations as transient\n- `IRequestHandler\u003c\u003e` concrete implementations as transient\n- `INotificationHandler\u003c\u003e` concrete implementations as transient\n- `IStreamRequestHandler\u003c\u003e` concrete implementations as transient\n- `IRequestExceptionHandler\u003c,,\u003e` concrete implementations as transient\n- `IRequestExceptionAction\u003c,\u003e)` concrete implementations as transient\n\nThis also registers open generic implementations for:\n\n- `INotificationHandler\u003c\u003e`\n- `IRequestExceptionHandler\u003c,,\u003e`\n- `IRequestExceptionAction\u003c,\u003e`\n\nTo register behaviors, stream behaviors, pre/post processors:\n\n```csharp\nservices.AddMediatR(cfg =\u003e {\n    cfg.RegisterServicesFromAssembly(typeof(Startup).Assembly);\n    cfg.AddBehavior\u003cPingPongBehavior\u003e();\n    cfg.AddStreamBehavior\u003cPingPongStreamBehavior\u003e();\n    cfg.AddRequestPreProcessor\u003cPingPreProcessor\u003e();\n    cfg.AddRequestPostProcessor\u003cPingPongPostProcessor\u003e();\n    cfg.AddOpenBehavior(typeof(GenericBehavior\u003c,\u003e));\n    });\n```\n\nWith additional methods for open generics and overloads for explicit service types.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbogard%2FMediatR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbogard%2FMediatR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbogard%2FMediatR/lists"}