Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
Dependency context loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogard committed Jul 19, 2016
1 parent 126d926 commit 6c29bb8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Expand Up @@ -5,9 +5,25 @@
using System.Linq;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
#if DEPENDENCY_MODEL
using Microsoft.Extensions.DependencyModel;
#endif

public static class ServiceCollectionExtensions
{
#if DEPENDENCY_MODEL
public static void AddMediatR(this IServiceCollection services)
{
services.AddMediatR(DependencyContext.Default);
}

public static void AddMediatR(this IServiceCollection services, DependencyContext dependencyContext)
{
services.AddMediatR(dependencyContext.RuntimeLibraries
.SelectMany(lib => lib.GetDefaultAssemblyNames(dependencyContext).Select(Assembly.Load)));
}
#endif

public static void AddMediatR(this IServiceCollection services, params Assembly[] assemblies)
{
AddRequiredServices(services);
Expand Down
19 changes: 17 additions & 2 deletions src/MediatR.Extensions.Microsoft.DependencyInjection/project.json
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "1.1.0-alpha-*",
"authors": [ "Jimmy Bogard" ],
"copyright": "Copyright Jimmy Bogard",
"description": "MediatR extensions for ASP.NET Core",
Expand All @@ -24,12 +24,27 @@
"net451": {
"frameworkAssemblies": {
"System.Runtime": ""
},
"dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.0"
},
"buildOptions": {
"define": [ "DEPENDENCY_MODEL" ]
}
},
"netstandard1.1": {
"dependencies": {
"NETStandard.Library": "1.6.0"
}
}
},
"netstandard1.6": {
"dependencies": {
"NETStandard.Library": "1.6.0",
"Microsoft.Extensions.DependencyModel": "1.0.0"
},
"buildOptions": {
"define": [ "DEPENDENCY_MODEL" ]
}
}
}
}

0 comments on commit 6c29bb8

Please sign in to comment.