Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b21fbef
commit 84c8c7a
Showing
17 changed files
with
511 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,45 @@ | ||
build_output/* | ||
build_artifacts/* | ||
build_temp/* | ||
*.suo | ||
*.user | ||
packages | ||
*.dotCover | ||
|
||
*.ncrunch* | ||
.vs | ||
|
||
.fake | ||
|
||
src/logs/* | ||
|
||
**/*.sln* | ||
bin | ||
obj | ||
_ReSharper* | ||
|
||
*.csproj.user | ||
*.resharper.user | ||
*.resharper | ||
*.ReSharper | ||
*.cache | ||
*~ | ||
*.swp | ||
*.bak | ||
*.orig | ||
|
||
NuGet.exe | ||
packages | ||
|
||
TestResult.xml | ||
submit.xml | ||
tests/* | ||
SolutionVersion.cs | ||
src/SolutionVersion.cs | ||
tests | ||
doc/build/* | ||
|
||
# osx noise | ||
.DS_Store | ||
build_output/* | ||
build_artifacts/* | ||
build_temp/* | ||
*.suo | ||
*.user | ||
packages | ||
*.dotCover | ||
|
||
*.ncrunch* | ||
.vs | ||
|
||
.fake | ||
|
||
src/logs/* | ||
|
||
**/*.sln* | ||
bin | ||
obj | ||
_ReSharper* | ||
|
||
*.csproj.user | ||
*.resharper.user | ||
*.resharper | ||
*.ReSharper | ||
*.cache | ||
*~ | ||
*.swp | ||
*.bak | ||
*.orig | ||
|
||
NuGet.exe | ||
packages | ||
|
||
TestResult.xml | ||
submit.xml | ||
tests/* | ||
SolutionVersion.cs | ||
src/SolutionVersion.cs | ||
tests | ||
doc/build/* | ||
|
||
# osx noise | ||
.DS_Store | ||
*.DotSettings | ||
/src/MassTransit.SimpleInjectorIntegration/MassTransit.SimpleInjectorIntegration.csproj.nuspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/Containers/MassTransit.Containers.Tests/SimpleInjector_Specs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
namespace MassTransit.Containers.Tests | ||
{ | ||
using MassTransit.Containers.Tests.Scenarios; | ||
using MassTransit.Saga; | ||
using MassTransit.SimpleInjectorIntegration; | ||
|
||
using NUnit.Framework; | ||
|
||
using SimpleInjector; | ||
using SimpleInjector.Extensions.ExecutionContextScoping; | ||
|
||
public class SimpleInjector_Consumer : | ||
When_registering_a_consumer | ||
{ | ||
[TearDown] | ||
public void Close_container() | ||
{ | ||
_container.Dispose(); | ||
} | ||
|
||
readonly Container _container; | ||
|
||
public SimpleInjector_Consumer() | ||
{ | ||
_container = new Container(); | ||
_container.Options.DefaultScopedLifestyle = new ExecutionContextScopeLifestyle(); | ||
_container.Register<SimpleConsumer>(Lifestyle.Scoped); | ||
_container.Register<ISimpleConsumerDependency, SimpleConsumerDependency>( | ||
Lifestyle.Scoped); | ||
_container.Register<AnotherMessageConsumer, AnotherMessageConsumerImpl>( | ||
Lifestyle.Scoped); | ||
} | ||
|
||
protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator) | ||
{ | ||
configurator.LoadFrom(_container); | ||
} | ||
} | ||
|
||
|
||
public class SimpleInjector_Saga : | ||
When_registering_a_saga | ||
{ | ||
[TestFixtureTearDown] | ||
public void Close_container() | ||
{ | ||
_container.Dispose(); | ||
} | ||
|
||
readonly Container _container; | ||
|
||
public SimpleInjector_Saga() | ||
{ | ||
_container = new Container(); | ||
_container.Options.DefaultScopedLifestyle = new ExecutionContextScopeLifestyle(); | ||
_container.Register(typeof(ISagaRepository<>), typeof(InMemorySagaRepository<>), | ||
Lifestyle.Singleton); | ||
} | ||
|
||
protected override void ConfigureInputQueueEndpoint(IReceiveEndpointConfigurator configurator) | ||
{ | ||
configurator.Saga<SimpleSaga>(_container); | ||
} | ||
|
||
protected override ISagaRepository<T> GetSagaRepository<T>() | ||
{ | ||
return _container.GetInstance<ISagaRepository<T>>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Containers/MassTransit.SimpleInjectorIntegration/ConsumerConfiguratorCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace MassTransit.SimpleInjectorIntegration | ||
{ | ||
using System; | ||
using System.Collections.Concurrent; | ||
|
||
using SimpleInjector; | ||
|
||
public static class ConsumerConfiguratorCache | ||
{ | ||
static CachedConfigurator GetOrAdd(Type type) | ||
{ | ||
return Cached.Instance.GetOrAdd(type, _ => | ||
(CachedConfigurator)Activator.CreateInstance(typeof(CachedConfigurator<>).MakeGenericType(type))); | ||
} | ||
|
||
public static void Configure(Type consumerType, IReceiveEndpointConfigurator configurator, Container container) | ||
{ | ||
GetOrAdd(consumerType).Configure(configurator, container); | ||
} | ||
|
||
interface CachedConfigurator | ||
{ | ||
void Configure(IReceiveEndpointConfigurator configurator, Container container); | ||
} | ||
|
||
class CachedConfigurator<T> : | ||
CachedConfigurator | ||
where T : class, IConsumer | ||
{ | ||
public void Configure(IReceiveEndpointConfigurator configurator, Container container) | ||
{ | ||
configurator.Consumer(new SimpleInjectorConsumerFactory<T>(container)); | ||
} | ||
} | ||
|
||
static class Cached | ||
{ | ||
internal static readonly ConcurrentDictionary<Type, CachedConfigurator> Instance = | ||
new ConcurrentDictionary<Type, CachedConfigurator>(); | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...ainers/MassTransit.SimpleInjectorIntegration/MassTransit.SimpleInjectorIntegration.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{259E9F30-40EC-47B0-83AE-A2271EF3421D}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>MassTransit.SimpleInjectorIntegration</RootNamespace> | ||
<AssemblyName>MassTransit.SimpleInjectorIntegration</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="SimpleInjector, Version=3.1.0.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\SimpleInjector.3.1.0\lib\net45\SimpleInjector.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="SimpleInjector.Extensions.ExecutionContextScoping, Version=3.1.0.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\SimpleInjector.Extensions.ExecutionContextScoping.3.1.0\lib\net45\SimpleInjector.Extensions.ExecutionContextScoping.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\..\SolutionVersion.cs"> | ||
<Link>SolutionVersion.cs</Link> | ||
</Compile> | ||
<Compile Include="ConsumerConfiguratorCache.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="SagaConfiguratorCache.cs" /> | ||
<Compile Include="SimpleInjectorConsumerFactory.cs" /> | ||
<Compile Include="SimpleInjectorExtensions.cs" /> | ||
<Compile Include="SimpleInjectorSagaRepository.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="app.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\MassTransit\MassTransit.csproj"> | ||
<Project>{6EFD69FC-CBCC-4F85-AEE0-EFBA73F4D273}</Project> | ||
<Name>MassTransit</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> | ||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | ||
</PropertyGroup> | ||
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> | ||
</Target> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
1 change: 1 addition & 0 deletions
1
src/Containers/MassTransit.SimpleInjectorIntegration/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Oops, something went wrong.