diff --git a/Build.ps1 b/Build.ps1
index aa6cf417..ef1f2b1d 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -30,20 +30,7 @@ exec { & dotnet clean -c Release }
exec { & dotnet build -c Release }
-exec { & dotnet test -c Release -r $artifacts --no-build -l trx --verbosity=normal }
-
-$samples = Get-ChildItem .\samples\MediatR.Examples.*
-
-foreach ($sample in $samples) {
- Push-Location -Path $sample
-
- try {
- exec { & dotnet run -c Release --no-build --no-restore }
- } catch {
- } finally {
- Pop-Location
- }
-}
+exec { & dotnet test -c Release --no-build -l trx --verbosity=normal }
exec { & dotnet pack .\src\MediatR\MediatR.csproj -c Release -o $artifacts --no-build }
diff --git a/MediatR.sln b/MediatR.sln
index 461fea7b..d8302f15 100644
--- a/MediatR.sln
+++ b/MediatR.sln
@@ -7,28 +7,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6267E2ED-942
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{962C5ACA-AB2B-4E9B-9EBB-7E7EE28CDBB1}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR", "src\MediatR\MediatR.csproj", "{12DA3F16-060B-467A-993F-2DF25EE6E6A8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Tests", "test\MediatR.Tests\MediatR.Tests.csproj", "{4FB0CFC4-90E3-467F-9704-6FBF637F9B4B}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples", "samples\MediatR.Examples\MediatR.Examples.csproj", "{18AB74EF-6E32-42C5-B6C4-159624CEDC5D}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.Autofac", "samples\MediatR.Examples.Autofac\MediatR.Examples.Autofac.csproj", "{DD286AB8-BA96-4476-82DF-371275EA8C10}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.LightInject", "samples\MediatR.Examples.LightInject\MediatR.Examples.LightInject.csproj", "{0A0796F1-A0BE-4D15-A8F3-B6EFA41CAF0B}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.SimpleInjector", "samples\MediatR.Examples.SimpleInjector\MediatR.Examples.SimpleInjector.csproj", "{A7FB2047-A4A0-4630-8C4C-31E7FA6ED902}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.StructureMap", "samples\MediatR.Examples.StructureMap\MediatR.Examples.StructureMap.csproj", "{7487E97A-CDA0-454D-8F62-CEE376DD3C3E}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.Windsor", "samples\MediatR.Examples.Windsor\MediatR.Examples.Windsor.csproj", "{BFF350A1-4FB1-4355-8437-675605BF8C52}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.DryIoc", "samples\MediatR.Examples.DryIoc\MediatR.Examples.DryIoc.csproj", "{24A1217D-8438-45DA-A802-0A3A7A3DDFD1}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.AspNetCore", "samples\MediatR.Examples.AspNetCore\MediatR.Examples.AspNetCore.csproj", "{4A255E84-AAC5-4ED9-ABAC-822804DBA4F1}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1E133765-6B4E-46C2-8C6C-7238E8EABA79}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
@@ -41,16 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.github\workflows\release.yml = .github\workflows\release.yml
EndProjectSection
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.Unity", "samples\MediatR.Examples.Unity\MediatR.Examples.Unity.csproj", "{E6C51E44-59B4-4F4F-AFB3-4032CDDEF07A}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.Lamar", "samples\MediatR.Examples.Lamar\MediatR.Examples.Lamar.csproj", "{F014598D-8B85-4D7E-942A-3493107ABE43}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.PublishStrategies", "samples\MediatR.Examples.PublishStrategies\MediatR.Examples.PublishStrategies.csproj", "{867EBA13-62F4-4525-8F92-B0AD828EE6D4}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Benchmarks", "test\MediatR.Benchmarks\MediatR.Benchmarks.csproj", "{1FA62162-F8F1-4CAD-B08E-8DCA603395AD}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Examples.Stashbox", "samples\MediatR.Examples.Stashbox\MediatR.Examples.Stashbox.csproj", "{575EC49E-BEC8-4DFF-BD22-8464844093FE}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MediatR.Contracts", "src\MediatR.Contracts\MediatR.Contracts.csproj", "{87F5A238-44B5-4769-82E5-E68B712D6E6D}"
EndProject
Global
@@ -67,58 +41,10 @@ Global
{4FB0CFC4-90E3-467F-9704-6FBF637F9B4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FB0CFC4-90E3-467F-9704-6FBF637F9B4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4FB0CFC4-90E3-467F-9704-6FBF637F9B4B}.Release|Any CPU.Build.0 = Release|Any CPU
- {18AB74EF-6E32-42C5-B6C4-159624CEDC5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {18AB74EF-6E32-42C5-B6C4-159624CEDC5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {18AB74EF-6E32-42C5-B6C4-159624CEDC5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {18AB74EF-6E32-42C5-B6C4-159624CEDC5D}.Release|Any CPU.Build.0 = Release|Any CPU
- {DD286AB8-BA96-4476-82DF-371275EA8C10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DD286AB8-BA96-4476-82DF-371275EA8C10}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DD286AB8-BA96-4476-82DF-371275EA8C10}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DD286AB8-BA96-4476-82DF-371275EA8C10}.Release|Any CPU.Build.0 = Release|Any CPU
- {0A0796F1-A0BE-4D15-A8F3-B6EFA41CAF0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0A0796F1-A0BE-4D15-A8F3-B6EFA41CAF0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0A0796F1-A0BE-4D15-A8F3-B6EFA41CAF0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0A0796F1-A0BE-4D15-A8F3-B6EFA41CAF0B}.Release|Any CPU.Build.0 = Release|Any CPU
- {A7FB2047-A4A0-4630-8C4C-31E7FA6ED902}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A7FB2047-A4A0-4630-8C4C-31E7FA6ED902}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A7FB2047-A4A0-4630-8C4C-31E7FA6ED902}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A7FB2047-A4A0-4630-8C4C-31E7FA6ED902}.Release|Any CPU.Build.0 = Release|Any CPU
- {7487E97A-CDA0-454D-8F62-CEE376DD3C3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7487E97A-CDA0-454D-8F62-CEE376DD3C3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7487E97A-CDA0-454D-8F62-CEE376DD3C3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7487E97A-CDA0-454D-8F62-CEE376DD3C3E}.Release|Any CPU.Build.0 = Release|Any CPU
- {BFF350A1-4FB1-4355-8437-675605BF8C52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BFF350A1-4FB1-4355-8437-675605BF8C52}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BFF350A1-4FB1-4355-8437-675605BF8C52}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BFF350A1-4FB1-4355-8437-675605BF8C52}.Release|Any CPU.Build.0 = Release|Any CPU
- {24A1217D-8438-45DA-A802-0A3A7A3DDFD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {24A1217D-8438-45DA-A802-0A3A7A3DDFD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {24A1217D-8438-45DA-A802-0A3A7A3DDFD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {24A1217D-8438-45DA-A802-0A3A7A3DDFD1}.Release|Any CPU.Build.0 = Release|Any CPU
- {4A255E84-AAC5-4ED9-ABAC-822804DBA4F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4A255E84-AAC5-4ED9-ABAC-822804DBA4F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4A255E84-AAC5-4ED9-ABAC-822804DBA4F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4A255E84-AAC5-4ED9-ABAC-822804DBA4F1}.Release|Any CPU.Build.0 = Release|Any CPU
- {E6C51E44-59B4-4F4F-AFB3-4032CDDEF07A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E6C51E44-59B4-4F4F-AFB3-4032CDDEF07A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E6C51E44-59B4-4F4F-AFB3-4032CDDEF07A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E6C51E44-59B4-4F4F-AFB3-4032CDDEF07A}.Release|Any CPU.Build.0 = Release|Any CPU
- {F014598D-8B85-4D7E-942A-3493107ABE43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F014598D-8B85-4D7E-942A-3493107ABE43}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F014598D-8B85-4D7E-942A-3493107ABE43}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F014598D-8B85-4D7E-942A-3493107ABE43}.Release|Any CPU.Build.0 = Release|Any CPU
- {867EBA13-62F4-4525-8F92-B0AD828EE6D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {867EBA13-62F4-4525-8F92-B0AD828EE6D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {867EBA13-62F4-4525-8F92-B0AD828EE6D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {867EBA13-62F4-4525-8F92-B0AD828EE6D4}.Release|Any CPU.Build.0 = Release|Any CPU
{1FA62162-F8F1-4CAD-B08E-8DCA603395AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1FA62162-F8F1-4CAD-B08E-8DCA603395AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1FA62162-F8F1-4CAD-B08E-8DCA603395AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1FA62162-F8F1-4CAD-B08E-8DCA603395AD}.Release|Any CPU.Build.0 = Release|Any CPU
- {575EC49E-BEC8-4DFF-BD22-8464844093FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {575EC49E-BEC8-4DFF-BD22-8464844093FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {575EC49E-BEC8-4DFF-BD22-8464844093FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {575EC49E-BEC8-4DFF-BD22-8464844093FE}.Release|Any CPU.Build.0 = Release|Any CPU
{87F5A238-44B5-4769-82E5-E68B712D6E6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87F5A238-44B5-4769-82E5-E68B712D6E6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87F5A238-44B5-4769-82E5-E68B712D6E6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -130,19 +56,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{12DA3F16-060B-467A-993F-2DF25EE6E6A8} = {6267E2ED-942C-497D-BFC9-B3CE0AFC276F}
{4FB0CFC4-90E3-467F-9704-6FBF637F9B4B} = {962C5ACA-AB2B-4E9B-9EBB-7E7EE28CDBB1}
- {18AB74EF-6E32-42C5-B6C4-159624CEDC5D} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
- {DD286AB8-BA96-4476-82DF-371275EA8C10} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
- {0A0796F1-A0BE-4D15-A8F3-B6EFA41CAF0B} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
- {A7FB2047-A4A0-4630-8C4C-31E7FA6ED902} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
- {7487E97A-CDA0-454D-8F62-CEE376DD3C3E} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
- {BFF350A1-4FB1-4355-8437-675605BF8C52} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
- {24A1217D-8438-45DA-A802-0A3A7A3DDFD1} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
- {4A255E84-AAC5-4ED9-ABAC-822804DBA4F1} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
- {E6C51E44-59B4-4F4F-AFB3-4032CDDEF07A} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
- {F014598D-8B85-4D7E-942A-3493107ABE43} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
- {867EBA13-62F4-4525-8F92-B0AD828EE6D4} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
{1FA62162-F8F1-4CAD-B08E-8DCA603395AD} = {962C5ACA-AB2B-4E9B-9EBB-7E7EE28CDBB1}
- {575EC49E-BEC8-4DFF-BD22-8464844093FE} = {95CFF0CD-87A6-4CB6-A99F-42EAD0829E37}
{87F5A238-44B5-4769-82E5-E68B712D6E6D} = {6267E2ED-942C-497D-BFC9-B3CE0AFC276F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
diff --git a/samples/MediatR.Examples.AspNetCore/MediatR.Examples.AspNetCore.csproj b/samples/MediatR.Examples.AspNetCore/MediatR.Examples.AspNetCore.csproj
deleted file mode 100644
index dd0af346..00000000
--- a/samples/MediatR.Examples.AspNetCore/MediatR.Examples.AspNetCore.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- net6.0
- Exe
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/MediatR.Examples.AspNetCore/Program.cs b/samples/MediatR.Examples.AspNetCore/Program.cs
deleted file mode 100644
index ca7cb223..00000000
--- a/samples/MediatR.Examples.AspNetCore/Program.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using System.IO;
-using System.Threading.Tasks;
-using MediatR.Pipeline;
-using Microsoft.Extensions.DependencyInjection;
-
-
-namespace MediatR.Examples.AspNetCore;
-
-public static class Program
-{
- public static Task Main(string[] args)
- {
- var writer = new WrappingWriter(Console.Out);
- var mediator = BuildMediator(writer);
- return Runner.Run(mediator, writer, "ASP.NET Core DI", testStreams: true);
- }
-
- private static IMediator BuildMediator(WrappingWriter writer)
- {
- var services = new ServiceCollection();
-
- services.AddSingleton(writer);
-
- services.AddMediatR(typeof(Ping), typeof(Sing));
-
- services.AddScoped(typeof(IStreamRequestHandler), typeof(SingHandler));
-
- services.AddScoped(typeof(IPipelineBehavior<,>), typeof(GenericPipelineBehavior<,>));
- services.AddScoped(typeof(IRequestPreProcessor<>), typeof(GenericRequestPreProcessor<>));
- services.AddScoped(typeof(IRequestPostProcessor<,>), typeof(GenericRequestPostProcessor<,>));
- services.AddScoped(typeof(IStreamPipelineBehavior<,>), typeof(GenericStreamPipelineBehavior<,>));
-
- var provider = services.BuildServiceProvider();
-
- return provider.GetRequiredService();
- }
-}
\ No newline at end of file
diff --git a/samples/MediatR.Examples.Autofac/MediatR.Examples.Autofac.csproj b/samples/MediatR.Examples.Autofac/MediatR.Examples.Autofac.csproj
deleted file mode 100644
index ecc05080..00000000
--- a/samples/MediatR.Examples.Autofac/MediatR.Examples.Autofac.csproj
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- net6.0
- Exe
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/MediatR.Examples.Autofac/Program.cs b/samples/MediatR.Examples.Autofac/Program.cs
deleted file mode 100644
index 6c0f2d22..00000000
--- a/samples/MediatR.Examples.Autofac/Program.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-namespace MediatR.Examples.Autofac;
-
-using global::Autofac;
-using MediatR.Pipeline;
-using System;
-using System.IO;
-using System.Reflection;
-using System.Threading.Tasks;
-
-internal static class Program
-{
- public static Task Main(string[] args)
- {
- var writer = new WrappingWriter(Console.Out);
- var mediator = BuildMediator(writer);
-
- return Runner.Run(mediator, writer, "Autofac", testStreams: true);
- }
-
- private static IMediator BuildMediator(WrappingWriter writer)
- {
- var builder = new ContainerBuilder();
- builder.RegisterAssemblyTypes(typeof(IMediator).GetTypeInfo().Assembly).AsImplementedInterfaces();
-
- var mediatrOpenTypes = new[]
- {
- typeof(IRequestHandler<,>),
- typeof(IRequestExceptionHandler<,,>),
- typeof(IRequestExceptionAction<,>),
- typeof(INotificationHandler<>),
- typeof(IStreamRequestHandler<,>)
- };
-
- foreach (var mediatrOpenType in mediatrOpenTypes)
- {
- builder
- .RegisterAssemblyTypes(typeof(Ping).GetTypeInfo().Assembly)
- .AsClosedTypesOf(mediatrOpenType)
- // when having a single class implementing several handler types
- // this call will cause a handler to be called twice
- // in general you should try to avoid having a class implementing for instance `IRequestHandler<,>` and `INotificationHandler<>`
- // the other option would be to remove this call
- // see also https://github.com/jbogard/MediatR/issues/462
- .AsImplementedInterfaces();
- }
-
- builder.RegisterInstance(writer).As();
-
- // It appears Autofac returns the last registered types first
- builder.RegisterGeneric(typeof(GenericStreamPipelineBehavior<,>)).As(typeof(IStreamPipelineBehavior<,>));
-
- builder.RegisterGeneric(typeof(RequestPostProcessorBehavior<,>)).As(typeof(IPipelineBehavior<,>));
- builder.RegisterGeneric(typeof(RequestPreProcessorBehavior<,>)).As(typeof(IPipelineBehavior<,>));
- builder.RegisterGeneric(typeof(RequestExceptionActionProcessorBehavior<,>)).As(typeof(IPipelineBehavior<,>));
- builder.RegisterGeneric(typeof(RequestExceptionProcessorBehavior<,>)).As(typeof(IPipelineBehavior<,>));
- builder.RegisterGeneric(typeof(GenericRequestPreProcessor<>)).As(typeof(IRequestPreProcessor<>));
- builder.RegisterGeneric(typeof(GenericRequestPostProcessor<,>)).As(typeof(IRequestPostProcessor<,>));
- builder.RegisterGeneric(typeof(GenericPipelineBehavior<,>)).As(typeof(IPipelineBehavior<,>));
- builder.RegisterGeneric(typeof(ConstrainedRequestPostProcessor<,>)).As(typeof(IRequestPostProcessor<,>));
- builder.RegisterGeneric(typeof(ConstrainedPingedHandler<>)).As(typeof(INotificationHandler<>));
-
- builder.Register(ctx =>
- {
- var c = ctx.Resolve();
- return t => c.Resolve(t);
- });
-
- var container = builder.Build();
-
- // The below returns:
- // - RequestPreProcessorBehavior
- // - RequestPostProcessorBehavior
- // - GenericPipelineBehavior
- // - GenericStreamPipelineBehavior
- // - RequestExceptionActionProcessorBehavior
- // - RequestExceptionProcessorBehavior
-
- //var behaviors = container
- // .Resolve>>()
- // .ToList();
-
- var mediator = container.Resolve();
-
- return mediator;
- }
-}
\ No newline at end of file
diff --git a/samples/MediatR.Examples.DryIoc/MediatR.Examples.DryIoc.csproj b/samples/MediatR.Examples.DryIoc/MediatR.Examples.DryIoc.csproj
deleted file mode 100644
index 379a8cfe..00000000
--- a/samples/MediatR.Examples.DryIoc/MediatR.Examples.DryIoc.csproj
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- net6.0
- Exe
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/MediatR.Examples.DryIoc/Program.cs b/samples/MediatR.Examples.DryIoc/Program.cs
deleted file mode 100644
index eb3d9763..00000000
--- a/samples/MediatR.Examples.DryIoc/Program.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.IO;
-using System.Threading.Tasks;
-using DryIoc;
-
-namespace MediatR.Examples.DryIoc;
-
-class Program
-{
- static Task Main()
- {
- var writer = new WrappingWriter(Console.Out);
- var mediator = BuildMediator(writer);
-
- return Runner.Run(mediator, writer, "DryIoc");
- }
-
- private static IMediator BuildMediator(WrappingWriter writer)
- {
- var container = new Container();
-
- container.RegisterDelegate(r => r.Resolve);
- container.Use(writer);
-
- //Pipeline works out of the box here
-
- container.RegisterMany(new[] { typeof(IMediator).GetAssembly(), typeof(Ping).GetAssembly() }, Registrator.Interfaces);
-
- return container.Resolve();
- }
-}
\ No newline at end of file
diff --git a/samples/MediatR.Examples.DryIocZero/Container.Generated.cs b/samples/MediatR.Examples.DryIocZero/Container.Generated.cs
deleted file mode 100644
index d8aaf3be..00000000
--- a/samples/MediatR.Examples.DryIocZero/Container.Generated.cs
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
-The MIT License (MIT)
-
-Copyright (c) 2016 Maksim Volkau
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-/*
-========================================================================================================
-NOTE: The code below is generated automatically at compile-time and not supposed to be changed by hand.
-========================================================================================================
-There are 4 generation issues (may be not an error dependent on context):
-
-The issues with run-time registrations may be solved by `container.RegisterPlaceholder()`
-in Registrations.ttinclude. Then you can replace placeholders using `DryIocZero.Container.Register`
-at runtime.
-
---------------------------------------------------------------------------------------------------------
-1. MediatR.Pipeline.IRequestPreProcessor<>
-Error: Resolving open-generic service type is not possible for type: MediatR.Pipeline.IRequestPreProcessor<>.
-2. MediatR.Pipeline.IRequestPostProcessor<,> {ServiceKey=DefaultKey(0)}
-Error: Resolving open-generic service type is not possible for type: MediatR.Pipeline.IRequestPostProcessor<,>.
-3. MediatR.Pipeline.IRequestPostProcessor<,> {ServiceKey=DefaultKey(1)}
-Error: Resolving open-generic service type is not possible for type: MediatR.Pipeline.IRequestPostProcessor<,>.
-4. MediatR.INotificationHandler {RequiredServiceType=MediatR.INotificationHandler<>}
-Error: Open-generic service does not match with registered open-generic implementation constraints MediatR.Examples.ConstrainedPingedHandler<> when resolving: MediatR.Examples.ConstrainedPingedHandler<>: MediatR.INotificationHandler {RequiredServiceType=MediatR.INotificationHandler<>} #42
- from container.
-*/
-
-using System;
-using System.Linq; // for Enumerable.Cast method required by LazyEnumerable
-using System.Collections.Generic;
-using System.Threading;
-using ImTools;
-using static DryIocZero.ResolveManyResult;
-
-namespace DryIocZero
-{
- partial class Container
- {
- [ExcludeFromCodeCoverage]
- partial void GetLastGeneratedFactoryID(ref int lastFactoryID)
- {
- lastFactoryID = 60; // generated: equals to last used Factory.FactoryID
- }
-
- [ExcludeFromCodeCoverage]
- partial void ResolveGenerated(ref object service, Type serviceType)
- {
- if (serviceType == typeof(MediatR.INotificationHandler))
- service = Get10_INotificationHandler(this);
-
- else
- if (serviceType == typeof(MediatR.INotificationHandler))
- service = Get11_INotificationHandler(this);
-
- else
- if (serviceType == typeof(MediatR.IRequestHandler))
- service = Get12_IRequestHandler(this);
-
- else
- if (serviceType == typeof(MediatR.IRequest))
- service = Get13_IRequest(this);
-
- else
- if (serviceType == typeof(MediatR.IRequest))
- service = Get16_IRequest(this);
-
- else
- if (serviceType == typeof(MediatR.IRequestHandler))
- service = Get17_IRequestHandler(this);
-
- else
- if (serviceType == typeof(MediatR.IMediator))
- service = Get18_IMediator(this);
-
- else
- if (serviceType == typeof(MediatR.IRequest))
- service = Get19_IRequest(this);
-
- else
- if (serviceType == typeof(MediatR.INotificationHandler))
- service = Get20_INotificationHandler(this);
- }
-
- [ExcludeFromCodeCoverage]
- partial void ResolveGenerated(ref object service,
- Type serviceType, object serviceKey, Type requiredServiceType, Request preRequestParent, object[] args)
- {
- if (serviceType == typeof(MediatR.IPipelineBehavior))
- {
- if (DefaultKey.Of(0).Equals(serviceKey))
- service = Get0_IPipelineBehavior(this);
-
- else
- if (DefaultKey.Of(1).Equals(serviceKey))
- service = Get2_IPipelineBehavior(this);
-
- else
- if (DefaultKey.Of(2).Equals(serviceKey))
- service = Get4_IPipelineBehavior(this);
- }
-
- else
- if (serviceType == typeof(MediatR.IPipelineBehavior))
- {
- if (DefaultKey.Of(0).Equals(serviceKey))
- service = Get1_IPipelineBehavior(this);
-
- else
- if (DefaultKey.Of(1).Equals(serviceKey))
- service = Get3_IPipelineBehavior(this);
-
- else
- if (DefaultKey.Of(2).Equals(serviceKey))
- service = Get5_IPipelineBehavior(this);
- }
-
- else
- if (serviceType == typeof(MediatR.INotification))
- {
- if (DefaultKey.Of(0).Equals(serviceKey))
- service = Get6_INotification(this);
-
- else
- if (DefaultKey.Of(1).Equals(serviceKey))
- service = Get7_INotification(this);
- }
-
- else
- if (serviceType == typeof(MediatR.IBaseRequest))
- {
- if (DefaultKey.Of(0).Equals(serviceKey))
- service = Get8_IBaseRequest(this);
-
- else
- if (DefaultKey.Of(1).Equals(serviceKey))
- service = Get9_IBaseRequest(this);
- }
-
- else
- if (serviceType == typeof(MediatR.INotificationHandler))
- {
- if (DefaultKey.Of(0).Equals(serviceKey))
- service = Get14_INotificationHandler(this);
-
- else
- if (DefaultKey.Of(1).Equals(serviceKey))
- service = Get15_INotificationHandler(this);
- }
- }
-
- [ExcludeFromCodeCoverage]
- partial void ResolveManyGenerated(ref IEnumerable services, Type serviceType)
- {
- services = ResolveManyGenerated(serviceType);
- }
-
- [ExcludeFromCodeCoverage]
- private IEnumerable ResolveManyGenerated(Type serviceType)
- {
- if (serviceType == typeof(MediatR.IPipelineBehavior))
- {
- yield return Of(Get0_IPipelineBehavior, DefaultKey.Of(0), typeof(MediatR.IPipelineBehavior<,>));
- yield return Of(Get2_IPipelineBehavior, DefaultKey.Of(1), typeof(MediatR.IPipelineBehavior<,>));
- yield return Of(Get4_IPipelineBehavior, DefaultKey.Of(2), typeof(MediatR.IPipelineBehavior<,>));
- }
-
- if (serviceType == typeof(MediatR.IPipelineBehavior))
- {
- yield return Of(Get1_IPipelineBehavior, DefaultKey.Of(0), typeof(MediatR.IPipelineBehavior<,>));
- yield return Of(Get3_IPipelineBehavior, DefaultKey.Of(1), typeof(MediatR.IPipelineBehavior<,>));
- yield return Of(Get5_IPipelineBehavior, DefaultKey.Of(2), typeof(MediatR.IPipelineBehavior<,>));
- }
-
- if (serviceType == typeof(MediatR.INotification))
- {
- yield return Of(Get6_INotification, DefaultKey.Of(0));
- yield return Of(Get7_INotification, DefaultKey.Of(1));
- }
-
- if (serviceType == typeof(MediatR.IBaseRequest))
- {
- yield return Of(Get8_IBaseRequest, DefaultKey.Of(0));
- yield return Of(Get9_IBaseRequest, DefaultKey.Of(1));
- }
-
- if (serviceType == typeof(MediatR.INotificationHandler))
- {
- yield return Of(Get10_INotificationHandler);
- yield return Of(Get11_INotificationHandler); // co-variant
- }
-
- if (serviceType == typeof(MediatR.INotificationHandler))
- {
- yield return Of(Get11_INotificationHandler);
- }
-
- if (serviceType == typeof(MediatR.IRequestHandler))
- {
- yield return Of(Get12_IRequestHandler);
- }
-
- if (serviceType == typeof(MediatR.IRequest))
- {
- yield return Of(Get13_IRequest);
- }
-
- if (serviceType == typeof(MediatR.INotificationHandler))
- {
- yield return Of(Get14_INotificationHandler, DefaultKey.Of(0));
- yield return Of(Get15_INotificationHandler, DefaultKey.Of(1));
- yield return Of(Get20_INotificationHandler, typeof(MediatR.INotificationHandler<>));
- yield return Of(Get11_INotificationHandler); // co-variant
- }
-
- if (serviceType == typeof(MediatR.IRequest))
- {
- yield return Of(Get16_IRequest);
- }
-
- if (serviceType == typeof(MediatR.IRequestHandler))
- {
- yield return Of(Get17_IRequestHandler);
- }
-
- if (serviceType == typeof(MediatR.IMediator))
- {
- yield return Of(Get18_IMediator);
- }
-
- if (serviceType == typeof(MediatR.IRequest))
- {
- yield return Of(Get19_IRequest);
- }
-
- }
-
- // typeof(MediatR.IPipelineBehavior)
- internal static object Get0_IPipelineBehavior(IResolverContext r)
- {
- return new MediatR.Pipeline.RequestPostProcessorBehavior(new MediatR.Pipeline.IRequestPostProcessor[] { new MediatR.Examples.ConstrainedRequestPostProcessor((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IPipelineBehavior), typeof(MediatR.IPipelineBehavior<,>), (object)DefaultKey.Of(0), 48, FactoryType.Service, typeof(MediatR.Pipeline.RequestPostProcessorBehavior), Reuse.Transient, RequestFlags.IsResolutionCall).Push(typeof(System.Collections.Generic.IEnumerable>), default(System.Type), (object)null, 2, FactoryType.Wrapper, default(System.Type), Reuse.Transient, ((RequestFlags)0)).Push(typeof(MediatR.Pipeline.IRequestPostProcessor), default(System.Type), (object)DefaultKey.Of(0), IfUnresolved.ReturnDefaultIfNotRegistered, 49, FactoryType.Service, typeof(MediatR.Examples.ConstrainedRequestPostProcessor), Reuse.Transient, ((RequestFlags)0), 0), default(object[]))), new MediatR.Examples.GenericRequestPostProcessor((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IPipelineBehavior), typeof(MediatR.IPipelineBehavior<,>), (object)DefaultKey.Of(0), 48, FactoryType.Service, typeof(MediatR.Pipeline.RequestPostProcessorBehavior), Reuse.Transient, RequestFlags.IsResolutionCall).Push(typeof(System.Collections.Generic.IEnumerable>), default(System.Type), (object)null, 2, FactoryType.Wrapper, default(System.Type), Reuse.Transient, ((RequestFlags)0)).Push(typeof(MediatR.Pipeline.IRequestPostProcessor), default(System.Type), (object)DefaultKey.Of(1), IfUnresolved.ReturnDefaultIfNotRegistered, 50, FactoryType.Service, typeof(MediatR.Examples.GenericRequestPostProcessor), Reuse.Transient, ((RequestFlags)0), 0), default(object[]))) });
- }
-
- // typeof(MediatR.IPipelineBehavior)
- internal static object Get1_IPipelineBehavior(IResolverContext r)
- {
- return new MediatR.Pipeline.RequestPostProcessorBehavior(new MediatR.Pipeline.IRequestPostProcessor[] { new MediatR.Examples.GenericRequestPostProcessor((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IPipelineBehavior), typeof(MediatR.IPipelineBehavior<,>), (object)DefaultKey.Of(0), 51, FactoryType.Service, typeof(MediatR.Pipeline.RequestPostProcessorBehavior), Reuse.Transient, RequestFlags.IsResolutionCall).Push(typeof(System.Collections.Generic.IEnumerable>), default(System.Type), (object)null, 2, FactoryType.Wrapper, default(System.Type), Reuse.Transient, ((RequestFlags)0)).Push(typeof(MediatR.Pipeline.IRequestPostProcessor), default(System.Type), (object)DefaultKey.Of(1), IfUnresolved.ReturnDefaultIfNotRegistered, 52, FactoryType.Service, typeof(MediatR.Examples.GenericRequestPostProcessor), Reuse.Transient, ((RequestFlags)0), 0), default(object[]))) });
- }
-
- // typeof(MediatR.IPipelineBehavior)
- internal static object Get2_IPipelineBehavior(IResolverContext r)
- {
- return new MediatR.Pipeline.RequestPreProcessorBehavior(new MediatR.Pipeline.IRequestPreProcessor[] { new MediatR.Examples.GenericRequestPreProcessor((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IPipelineBehavior), typeof(MediatR.IPipelineBehavior<,>), (object)DefaultKey.Of(1), 53, FactoryType.Service, typeof(MediatR.Pipeline.RequestPreProcessorBehavior), Reuse.Transient, RequestFlags.IsResolutionCall).Push(typeof(System.Collections.Generic.IEnumerable>), default(System.Type), (object)null, 2, FactoryType.Wrapper, default(System.Type), Reuse.Transient, ((RequestFlags)0)).Push(typeof(MediatR.Pipeline.IRequestPreProcessor), default(System.Type), (object)DefaultKey.Of(0), IfUnresolved.ReturnDefaultIfNotRegistered, 54, FactoryType.Service, typeof(MediatR.Examples.GenericRequestPreProcessor), Reuse.Transient, ((RequestFlags)0), 0), default(object[]))) });
- }
-
- // typeof(MediatR.IPipelineBehavior)
- internal static object Get3_IPipelineBehavior(IResolverContext r)
- {
- return new MediatR.Pipeline.RequestPreProcessorBehavior(new MediatR.Pipeline.IRequestPreProcessor[] { new MediatR.Examples.GenericRequestPreProcessor((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IPipelineBehavior), typeof(MediatR.IPipelineBehavior<,>), (object)DefaultKey.Of(1), 55, FactoryType.Service, typeof(MediatR.Pipeline.RequestPreProcessorBehavior), Reuse.Transient, RequestFlags.IsResolutionCall).Push(typeof(System.Collections.Generic.IEnumerable>), default(System.Type), (object)null, 2, FactoryType.Wrapper, default(System.Type), Reuse.Transient, ((RequestFlags)0)).Push(typeof(MediatR.Pipeline.IRequestPreProcessor), default(System.Type), (object)DefaultKey.Of(0), IfUnresolved.ReturnDefaultIfNotRegistered, 56, FactoryType.Service, typeof(MediatR.Examples.GenericRequestPreProcessor), Reuse.Transient, ((RequestFlags)0), 0), default(object[]))) });
- }
-
- // typeof(MediatR.IPipelineBehavior)
- internal static object Get4_IPipelineBehavior(IResolverContext r)
- {
- return new MediatR.Examples.GenericPipelineBehavior((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IPipelineBehavior), typeof(MediatR.IPipelineBehavior<,>), (object)DefaultKey.Of(2), 57, FactoryType.Service, typeof(MediatR.Examples.GenericPipelineBehavior), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])));
- }
-
- // typeof(MediatR.IPipelineBehavior)
- internal static object Get5_IPipelineBehavior(IResolverContext r)
- {
- return new MediatR.Examples.GenericPipelineBehavior((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IPipelineBehavior), typeof(MediatR.IPipelineBehavior<,>), (object)DefaultKey.Of(2), 58, FactoryType.Service, typeof(MediatR.Examples.GenericPipelineBehavior), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])));
- }
-
- // typeof(MediatR.INotification)
- internal static object Get6_INotification(IResolverContext r)
- {
- return new MediatR.Examples.Pinged();
- }
-
- // typeof(MediatR.INotification)
- internal static object Get7_INotification(IResolverContext r)
- {
- return new MediatR.Examples.Ponged();
- }
-
- // typeof(MediatR.IBaseRequest)
- internal static object Get8_IBaseRequest(IResolverContext r)
- {
- return new MediatR.Examples.Jing();
- }
-
- // typeof(MediatR.IBaseRequest)
- internal static object Get9_IBaseRequest(IResolverContext r)
- {
- return new MediatR.Examples.Ping();
- }
-
- // typeof(MediatR.INotificationHandler)
- internal static object Get10_INotificationHandler(IResolverContext r)
- {
- return new MediatR.Examples.PongedHandler((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.INotificationHandler), default(System.Type), (object)null, 41, FactoryType.Service, typeof(MediatR.Examples.PongedHandler), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])));
- }
-
- // typeof(MediatR.INotificationHandler)
- internal static object Get11_INotificationHandler(IResolverContext r)
- {
- return new MediatR.Examples.GenericHandler((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.INotificationHandler), default(System.Type), (object)null, 32, FactoryType.Service, typeof(MediatR.Examples.GenericHandler), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])));
- }
-
- // typeof(MediatR.IRequestHandler)
- internal static object Get12_IRequestHandler(IResolverContext r)
- {
- return new MediatR.Examples.PingHandler((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IRequestHandler), default(System.Type), (object)null, 44, FactoryType.Service, typeof(MediatR.Examples.PingHandler), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])));
- }
-
- // typeof(MediatR.IRequest)
- internal static object Get13_IRequest(IResolverContext r)
- {
- return new MediatR.Examples.Ping();
- }
-
- // typeof(MediatR.INotificationHandler)
- internal static object Get14_INotificationHandler(IResolverContext r)
- {
- return new MediatR.Examples.PingedHandler((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.INotificationHandler), default(System.Type), (object)DefaultKey.Of(0), 40, FactoryType.Service, typeof(MediatR.Examples.PingedHandler), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])));
- }
-
- // typeof(MediatR.INotificationHandler)
- internal static object Get15_INotificationHandler(IResolverContext r)
- {
- return new MediatR.Examples.PingedAlsoHandler((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.INotificationHandler), default(System.Type), (object)DefaultKey.Of(1), 43, FactoryType.Service, typeof(MediatR.Examples.PingedAlsoHandler), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])));
- }
-
- // typeof(MediatR.IRequest)
- internal static object Get16_IRequest(IResolverContext r)
- {
- return new MediatR.Examples.Jing();
- }
-
- // typeof(MediatR.IRequestHandler)
- internal static object Get17_IRequestHandler(IResolverContext r)
- {
- return new MediatR.Examples.JingHandler((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IRequestHandler), default(System.Type), (object)null, 37, FactoryType.Service, typeof(MediatR.Examples.JingHandler), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])));
- }
-
- // typeof(MediatR.IMediator)
- internal static object Get18_IMediator(IResolverContext r)
- {
- return new MediatR.Mediator((MediatR.ServiceFactory)r.Resolve(typeof(MediatR.ServiceFactory), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.IMediator), default(System.Type), (object)null, 28, FactoryType.Service, typeof(MediatR.Mediator), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])));
- }
-
- // typeof(MediatR.IRequest)
- internal static object Get19_IRequest(IResolverContext r)
- {
- return new MediatR.Examples.Jing();
- }
-
- // typeof(MediatR.INotificationHandler)
- internal static object Get20_INotificationHandler(IResolverContext r)
- {
- return new MediatR.Examples.ConstrainedPingedHandler((System.IO.TextWriter)r.Resolve(typeof(System.IO.TextWriter), null, IfUnresolved.Throw, default(System.Type), Request.Empty.Push(typeof(MediatR.INotificationHandler), typeof(MediatR.INotificationHandler<>), (object)null, 59, FactoryType.Service, typeof(MediatR.Examples.ConstrainedPingedHandler), Reuse.Transient, RequestFlags.IsResolutionCall), default(object[])));
- }
-
- }
-}
diff --git a/samples/MediatR.Examples.DryIocZero/Container.Generated.tt b/samples/MediatR.Examples.DryIocZero/Container.Generated.tt
deleted file mode 100644
index 69331fc5..00000000
--- a/samples/MediatR.Examples.DryIocZero/Container.Generated.tt
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
-The MIT License (MIT)
-
-Copyright (c) 2016 Maksim Volkau
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-<#@ template debug="false" hostspecific="true" language="C#" #>
-<#@ output extension=".cs" #>
-<#@ CleanupBehavior processor="T4VSHost" CleanupAfterProcessingtemplate="true" #>
-<#@ assembly Name="$(DryIocAssembly)" #>
-<#@ assembly Name="$(ExpressionToCodeLibAssembly)" #>
-<#@ import Namespace="DryIoc" #>
-<#@ import Namespace="ImTools" #>
-<#@ import Namespace="ExpressionToCodeLib" #>
-<#@ assembly Name="System.Core" #>
-<#@ assembly Name="System.Runtime" #>
-<#@ import Namespace="System.Linq" #>
-<#@ import Namespace="System.Linq.Expressions" #>
-<#@ include File="$(ProjectDir)\Registrations.ttinclude" #>
-<#
-var container = GetContainerWithRegistrations()
- .With(rules => rules.WithThrowIfRuntimeStateRequired());
-
-var includeVariants = container.Rules.VariantGenericTypesInResolvedCollection;
-
-var result = container.GenerateResolutionExpressions(regs => regs.SelectMany(r =>
- SpecifyResolutionRoots(r).EmptyIfNull()).Concat(CustomResolutionRoots.EmptyIfNull()));
-
-var exprToCode = ExpressionToCodeConfiguration.DefaultCodeGenConfiguration
- .WithObjectStringifier(ObjectStringify.WithFullTypeNames);
-
-string Code(object x) =>
- x == null ? "null" :
- x is Expression ? exprToCode.ToCode((Expression)x)
- .Replace("DryIoc." + nameof(IfUnresolved), nameof(IfUnresolved))
- .Replace("DryIoc." + nameof(IReuse), nameof(IReuse))
- .Replace("DryIoc." + nameof(Reuse), nameof(Reuse))
- .Replace("DryIoc." + nameof(SingletonReuse), nameof(SingletonReuse))
- .Replace("DryIoc." + nameof(CurrentScopeReuse), nameof(CurrentScopeReuse))
- .Replace("DryIoc." + nameof(FactoryType), nameof(FactoryType))
- .Replace("DryIoc." + nameof(DefaultKey), nameof(DefaultKey))
- .Replace("DryIoc." + nameof(DefaultDynamicKey), nameof(DefaultDynamicKey))
- .Replace("DryIoc." + nameof(Request), nameof(Request))
- .Replace("DryIoc." + nameof(RequestFlags), nameof(RequestFlags))
- .Replace("DryIoc." + nameof(HiddenDisposable), nameof(HiddenDisposable))
- .Replace("DryIoc." + nameof(ResolutionScopeName), nameof(ResolutionScopeName))
- .Replace("DryIoc." + nameof(CompositeScopeName), nameof(CompositeScopeName))
- : x is Request ? Code(container.GetRequestExpression((Request)x).ToExpression())
- : Code(container.GetConstantExpression(x, x.GetType(), true).ToExpression());
-
-string GetTypeNameOnly(string typeName) => typeName.Split('`').First().Split('.').Last();
-
-string OptArg(string arg) => arg == "null" ? "" : ", " + arg;
-
-var rootCodes = result.Roots.Select((r, i) =>
- new { ServiceType = r.Key.ServiceType,
- ServiceTypeCode = Code(r.Key.ServiceType),
- ServiceKeyCode = Code(r.Key.ServiceKey),
- RequiredServiceTypeCode = Code(r.Key.Details.RequiredServiceType),
- ExpressionCode = Code(r.Value.Body),
- CreateMethodName = "Get" + i + "_" + GetTypeNameOnly(r.Key.ServiceType.Name) });
-
-var depCodes = result.ResolveDependencies.Select((r, i) =>
- new { ServiceType = Code(r.Key.ServiceType),
- ServiceKey = Code(r.Key.ServiceKey), ServiceKeyObject = r.Key.ServiceKey,
- Expression = Code(r.Value),
- RequiredServiceType = Code(r.Key.RequiredServiceType),
- PreResolveParent = Code(r.Key.Parent),
- CreateMethodName = "GetDep" + i + "_" + GetTypeNameOnly(r.Key.ServiceType.Name) });
-#>
-/*
-========================================================================================================
-NOTE: The code below is generated automatically at compile-time and not supposed to be changed by hand.
-========================================================================================================
-<# var errCount = result.Errors.Count;
- if (errCount == 0) { #>
-Generation is completed successfully.
-<# } else { #>
-There are <#=errCount#> generation issues (may be not an error dependent on context):
-
-The issues with run-time registrations may be solved by `container.RegisterPlaceholder()`
-in Registrations.ttinclude. Then you can replace placeholders using `DryIocZero.Container.Register`
-at runtime.
-
-<# } #>
---------------------------------------------------------------------------------------------------------
-<# var eNum = 0;
- foreach(var e in result.Errors) { #>
-<#=++eNum#>. <#=e.Key#>
-Error: <#=e.Value.Message#>
-<# } #>
-*/
-
-using System;
-using System.Linq; // for Enumerable.Cast method required by LazyEnumerable
-using System.Collections.Generic;
-using System.Threading;
-using ImTools;
-using static DryIocZero.ResolveManyResult;
-
-namespace DryIocZero
-{
- partial class Container
- {
- [ExcludeFromCodeCoverage]
- partial void GetLastGeneratedFactoryID(ref int lastFactoryID)
- {
- lastFactoryID = <#=Factory.GetNextID()#>; // generated: equals to last used Factory.FactoryID
- }
-
- [ExcludeFromCodeCoverage]
- partial void ResolveGenerated(ref object service, Type serviceType)
- {
-<#
- var index = 0;
- foreach (var root in rootCodes.Where(f => f.ServiceKeyCode == "null"))
- {
- if (index++ > 0) WriteLine(@"
- else");
-#>
- if (serviceType == <#=root.ServiceTypeCode#>)
- service = <#=root.CreateMethodName#>(this);
-<#
- }
-#>
- }
-
- [ExcludeFromCodeCoverage]
- partial void ResolveGenerated(ref object service,
- Type serviceType, object serviceKey, Type requiredServiceType, Request preRequestParent, object[] args)
- {
-<#
- index = 0;
- foreach (var rootGroup in rootCodes.Where(x => x.ServiceKeyCode != "null").GroupBy(x => x.ServiceTypeCode))
- {
- if (index++ > 0) WriteLine(@"
- else");
-#>
- if (serviceType == <#=rootGroup.Key#>)
- {
-<#
- var innerIndex = 0;
- foreach (var root in rootGroup)
- {
- if (innerIndex++ > 0) WriteLine(@"
- else");
-#>
- if (<#=root.ServiceKeyCode#>.Equals(serviceKey))
- service = <#=root.CreateMethodName#>(this);
-<#
- }
-
-#>
- }
-<#
- }
-#>
-<#
- foreach (var depGroup in depCodes.GroupBy(x => x.ServiceType))
- {
- if (index++ > 0) WriteLine(@"
- else");
-#>
- if (serviceType == <#=depGroup.Key#>)
- {
-<#
- var innerIndex = 0;
- foreach (var dep in depGroup)
- {
- if (innerIndex++ > 0) WriteLine(@"
- else");
-#>
- if (<#=dep.ServiceKeyObject == null ? "serviceKey == null"
- : dep.ServiceKeyObject is DefaultKey ? "(serviceKey == null || " + dep.ServiceKey + ".Equals(serviceKey))"
- : dep.ServiceKey + ".Equals(serviceKey)"#> &&
- requiredServiceType == <#= dep.RequiredServiceType #> &&
- Equals(preRequestParent, <#= dep.PreResolveParent #>))
- service = <#=dep.CreateMethodName#>(this);
-<#
- }
-#>
- }
-<#
- }
-#>
- }
-
- [ExcludeFromCodeCoverage]
- partial void ResolveManyGenerated(ref IEnumerable services, Type serviceType)
- {
- services = ResolveManyGenerated(serviceType);
- }
-
- [ExcludeFromCodeCoverage]
- private IEnumerable ResolveManyGenerated(Type serviceType)
- {
-<#
- if (!rootCodes.Any())
- {
-#>
- yield break;
-<#
- }
- else
- {
- foreach (var rootGroup in rootCodes.GroupBy(x => x.ServiceType))
- {
-#>
- if (serviceType == <#=rootGroup.First().ServiceTypeCode#>)
- {
-<#
- foreach (var root in rootGroup)
- {
-#>
- yield return Of(<#=root.CreateMethodName#><#=OptArg(root.ServiceKeyCode)#><#=OptArg(root.RequiredServiceTypeCode)#>);
-<#
- }
-
- if (includeVariants && rootGroup.Key.IsGeneric())
- {
- var sourceType = rootGroup.Key;
- var variants = rootCodes
- .Where(x => x.ServiceType.IsGeneric() &&
- x.ServiceType.GetGenericTypeDefinition() == sourceType.GetGenericTypeDefinition() &&
- x.ServiceType != sourceType && x.ServiceType.IsAssignableTo(sourceType));
- foreach (var variant in variants)
- {
-#>
- yield return Of(<#=variant.CreateMethodName#><#=OptArg(variant.ServiceKeyCode)#><#=OptArg(variant.RequiredServiceTypeCode)#>); // co-variant
-<#
- }
- }
-#>
- }
-
-<#
- }
- }
-#>
- }
-
-<#
- foreach (var root in rootCodes)
- {
-#>
- // <#=root.ServiceTypeCode#>
- internal static object <#=root.CreateMethodName#>(IResolverContext r)
- {
- return <#=root.ExpressionCode#>;
- }
-
-<#
- }
-#>
-<#
- foreach (var dep in depCodes)
- {
-#>
- // <#=dep.ServiceType#>
- internal static object <#=dep.CreateMethodName#>(IResolverContext r)
- {
- return <#=dep.Expression#>;
- }
-
-<#
- }
-#>
- }
-}
diff --git a/samples/MediatR.Examples.DryIocZero/Container.cs b/samples/MediatR.Examples.DryIocZero/Container.cs
deleted file mode 100644
index 6203993b..00000000
--- a/samples/MediatR.Examples.DryIocZero/Container.cs
+++ /dev/null
@@ -1,1525 +0,0 @@
-/*
-The MIT License (MIT)
-
-Copyright (c) 2016 Maksim Volkau
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-namespace DryIocZero
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading;
- using ImTools;
-
- /// Minimal container to register service factory delegates and then resolve service from them.
- [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly",
- Justification = "Does not contain any unmanaged resources.")]
- public sealed partial class Container : IRegistrator, IResolverContext
- {
- /// Creates container.
- public Container(IScopeContext scopeContext = null)
- : this(Ref.Of(ImHashMap.Empty),
- Ref.Of(ImHashMap>.Empty),
- new Scope(name: ""), scopeContext,
- currentScope: null, disposed: 0, parent: null, root: null)
- { }
-
- /// Full constructor with all state included.
- public Container(Ref> defaultFactories,
- Ref>> keyedFactories,
- IScope singletonScope, IScopeContext scopeContext, IScope currentScope,
- int disposed, IResolverContext parent, IResolverContext root)
- {
- _defaultFactories = defaultFactories;
- _keyedFactories = keyedFactories;
-
- SingletonScope = singletonScope;
- ScopeContext = scopeContext;
- _currentScope = currentScope;
-
- _disposed = disposed;
-
- Parent = parent;
- Root = root;
-
- GetLastGeneratedFactoryID(ref _lastFactoryID);
- }
-
- private int _lastFactoryID;
-
- /// The unique factory ID, which may be used for runtime scoped registrations.
- public int GetNextFactoryID() => Interlocked.Increment(ref _lastFactoryID);
-
- #region IResolver
-
- partial void GetLastGeneratedFactoryID(ref int lastFactoryID);
-
- // todo: May be replace with TryResolveGenerated to accommodate for the possible null service
- partial void ResolveGenerated(ref object service, Type serviceType);
-
- /// Directly uses generated factories to resolve service. Or returns default if service does not have generated factory.
- [SuppressMessage("ReSharper", "InvocationIsSkipped", Justification = "Per design")]
- [SuppressMessage("ReSharper", "ExpressionIsAlwaysNull", Justification = "Per design")]
- public object ResolveGeneratedOrGetDefault(Type serviceType)
- {
- object service = null;
- ResolveGenerated(ref service, serviceType);
- return service;
- }
-
- /// Resolves service from container and returns created service object.
- [SuppressMessage("ReSharper", "InvocationIsSkipped", Justification = "Per design")]
- [SuppressMessage("ReSharper", "ConstantNullCoalescingCondition", Justification = "Per design")]
- public object Resolve(Type serviceType, IfUnresolved ifUnresolved)
- {
- object service = null;
- if (_defaultFactories.Value.IsEmpty)
- ResolveGenerated(ref service, serviceType);
- return service
- ?? ResolveDefaultFromRuntimeRegistrationsFirst(serviceType, ifUnresolved == IfUnresolved.ReturnDefault);
- }
-
- private object ResolveDefaultFromRuntimeRegistrationsFirst(Type serviceType, bool ifUnresolvedReturnDefault)
- {
- var factories = _defaultFactories.Value;
- var factory = factories.GetValueOrDefault(serviceType);
-
- object service = null;
- if (factory == null)
- ResolveGenerated(ref service, serviceType);
- else
- service = factory(this);
-
- return service ?? Throw.If(!ifUnresolvedReturnDefault,
- Error.UnableToResolveDefaultService, serviceType, factories.IsEmpty ? string.Empty : "non-");
- }
-
- // todo: May be replace with TryResolveGenerated to accommodate for the possible null service
- partial void ResolveGenerated(ref object service,
- Type serviceType, object serviceKey, Type requiredServiceType, Request preRequestParent, object[] args);
-
- /// Directly uses generated factories to resolve service. Or returns default if service does not have generated factory.
- [SuppressMessage("ReSharper", "InvocationIsSkipped", Justification = "Per design")]
- [SuppressMessage("ReSharper", "ExpressionIsAlwaysNull", Justification = "Per design")]
- public object ResolveGeneratedOrGetDefault(Type serviceType, object serviceKey)
- {
- object service = null;
- ResolveGenerated(ref service, serviceType, serviceKey,
- requiredServiceType: null, preRequestParent: null, args: null);
- return service;
- }
-
- /// Resolves service from container and returns created service object.
- [SuppressMessage("ReSharper", "InvocationIsSkipped", Justification = "Per design")]
- [SuppressMessage("ReSharper", "ConstantNullCoalescingCondition", Justification = "Per design")]
- object IResolver.Resolve(Type serviceType, object serviceKey,
- IfUnresolved ifUnresolved, Type requiredServiceType, Request preResolveParent, object[] args)
- {
- // if no runtime registrations, then fast resolve from generated delegates
- object service = null;
- if (_keyedFactories.Value.IsEmpty)
- {
- if (serviceKey == null && requiredServiceType == null && preResolveParent == null && args == null)
- ResolveGenerated(ref service, serviceType);
- else
- ResolveGenerated(ref service, serviceType, serviceKey, requiredServiceType, preResolveParent, args);
- }
-
- // if not resolved from generated fallback to check runtime registrations first
- return service
- ?? ResolveFromRuntimeRegistrationsFirst(serviceType, serviceKey,
- ifUnresolved == IfUnresolved.ReturnDefault, requiredServiceType, preResolveParent, args);
- }
-
- [SuppressMessage("ReSharper", "InvocationIsSkipped", Justification = "Per design")]
- [SuppressMessage("ReSharper", "ConstantNullCoalescingCondition", Justification = "Per design")]
- private object ResolveFromRuntimeRegistrationsFirst(Type serviceType, object serviceKey,
- bool ifUnresolvedReturnDefault, Type requiredServiceType, Request preResolveParent, object[] args)
- {
- serviceType = requiredServiceType ?? serviceType;
-
- // ignore the rest of arguments, e.g. preResolveParent when resolving the runtime substitutes
- if (serviceKey == null)
- return ResolveDefaultFromRuntimeRegistrationsFirst(serviceType, ifUnresolvedReturnDefault);
-
- FactoryDelegate factory;
- var factories = _keyedFactories.Value.GetValueOrDefault(serviceType);
- if (factories != null && (factory = factories.GetValueOrDefault(serviceKey)) != null)
- return factory(this);
-
- // If not resolved from runtime registration then try resolve generated
- object service = null;
- ResolveGenerated(ref service, serviceType,
- serviceKey, requiredServiceType, preResolveParent ?? Request.Empty, args);
-
- return service ?? Throw.If(!ifUnresolvedReturnDefault,
- Error.UnableToResolveKeyedService, serviceType, serviceKey, factories == null ? string.Empty : "non-");
- }
-
- partial void ResolveManyGenerated(ref IEnumerable services, Type serviceType);
-
- /// Resolves many generated only services. Ignores runtime registrations.
- public IEnumerable ResolveManyGeneratedOrGetEmpty(Type serviceType)
- {
- var manyGenerated = Enumerable.Empty();
- ResolveManyGenerated(ref manyGenerated, serviceType);
- return manyGenerated;
- }
-
- ///
- public IEnumerable