-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
6ce5509
commit be4c339
Showing
32 changed files
with
534 additions
and
11 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
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
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
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
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,7 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and ReflectionEventing Contributors. | ||
// All Rights Reserved. | ||
|
||
global using System; | ||
global using System.Collections.Generic; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and ReflectionEventing Contributors. | ||
// All Rights Reserved. | ||
|
||
using Ninject.Modules; | ||
|
||
namespace ReflectionEventing.Ninject; | ||
|
||
/// <summary> | ||
/// Represents a Ninject module for configuring the event bus. | ||
/// </summary> | ||
public class EventBusModule(Action<NinjectEventBusBuilder> configure) : NinjectModule | ||
{ | ||
/// <summary> | ||
/// Loads the module into the kernel. | ||
/// </summary> | ||
public override void Load() | ||
{ | ||
NinjectEventBusBuilder builder = new(Kernel); | ||
|
||
configure(builder); | ||
|
||
_ = Bind<IConsumerTypesProvider>() | ||
.To<HashedConsumerTypesProvider>() | ||
.InSingletonScope() | ||
.WithConstructorArgument("consumers", builder.GetConsumers()); | ||
|
||
_ = Bind<IConsumerProvider>().To<NinjectConsumerProvider>().InTransientScope(); | ||
|
||
_ = Bind<IEventBus>().To<EventBus>().InTransientScope(); | ||
} | ||
} |
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,8 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and ReflectionEventing Contributors. | ||
// All Rights Reserved. | ||
|
||
global using System; | ||
global using System.Collections.Generic; | ||
global using System.Linq; |
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,25 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and ReflectionEventing Contributors. | ||
// All Rights Reserved. | ||
|
||
using Ninject; | ||
|
||
namespace ReflectionEventing.Ninject; | ||
|
||
/// <summary> | ||
/// Provides event consumers for Ninject. | ||
/// </summary> | ||
public class NinjectConsumerProvider(IKernel kernel) : IConsumerProvider | ||
{ | ||
/// <inheritdoc /> | ||
public IEnumerable<object> GetConsumerTypes(Type consumerType) | ||
{ | ||
if (consumerType is null) | ||
{ | ||
throw new ArgumentNullException(nameof(consumerType)); | ||
} | ||
|
||
return kernel.GetAll(consumerType); | ||
} | ||
} |
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,25 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and ReflectionEventing Contributors. | ||
// All Rights Reserved. | ||
|
||
using Ninject; | ||
|
||
namespace ReflectionEventing.Ninject; | ||
|
||
/// <summary> | ||
/// Represents a builder for configuring the event bus with Ninject. | ||
/// </summary> | ||
public class NinjectEventBusBuilder(IKernel kernel) : EventBusBuilder | ||
{ | ||
/// <inheritdoc /> | ||
public override void AddConsumer(Type consumerType) | ||
{ | ||
if (!kernel.GetBindings(consumerType).Any()) | ||
{ | ||
throw new InvalidOperationException("Event consumer must be registered in the kernel."); | ||
} | ||
|
||
base.AddConsumer(consumerType); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/ReflectionEventing.Ninject/ReflectionEventing.Ninject.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,36 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<PackageId>ReflectionEventing.DependencyInjection</PackageId> | ||
<TargetFrameworks>net462;net472;net481</TargetFrameworks> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<IsTrimmable>true</IsTrimmable> | ||
<EnableTrimAnalyzer>true</EnableTrimAnalyzer> | ||
</PropertyGroup> | ||
|
||
<!-- Necessary polyfills --> | ||
<PropertyGroup> | ||
<PolySharpIncludeGeneratedTypes> | ||
System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute; | ||
System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute; | ||
System.Diagnostics.CodeAnalysis.MemberNotNullAttribute; | ||
System.Diagnostics.CodeAnalysis.NotNullAttribute; | ||
System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute; | ||
System.Diagnostics.CodeAnalysis.NotNullWhenAttribute; | ||
System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute; | ||
System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute; | ||
System.Runtime.CompilerServices.CallerArgumentExpressionAttribute; | ||
System.Runtime.CompilerServices.IsExternalInit; | ||
System.Runtime.CompilerServices.SkipLocalsInitAttribute; | ||
</PolySharpIncludeGeneratedTypes> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Ninject" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ReflectionEventing\ReflectionEventing.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,8 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and ReflectionEventing Contributors. | ||
// All Rights Reserved. | ||
|
||
global using System; | ||
global using System.Collections.Generic; | ||
global using System.Linq; |
42 changes: 42 additions & 0 deletions
42
src/ReflectionEventing.Unity/ReflectionEventing.Unity.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,42 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<PackageId>ReflectionEventing.DependencyInjection</PackageId> | ||
<TargetFrameworks>netstandard2.0;netstandard2.1;net462;net6.0;net8.0</TargetFrameworks> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<IsTrimmable>true</IsTrimmable> | ||
<EnableTrimAnalyzer>true</EnableTrimAnalyzer> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'"> | ||
<PublishAot>true</PublishAot> | ||
<StripSymbols>true</StripSymbols> | ||
<OptimizationPreference>Speed</OptimizationPreference> | ||
</PropertyGroup> | ||
|
||
<!-- Necessary polyfills --> | ||
<PropertyGroup> | ||
<PolySharpIncludeGeneratedTypes> | ||
System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute; | ||
System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute; | ||
System.Diagnostics.CodeAnalysis.MemberNotNullAttribute; | ||
System.Diagnostics.CodeAnalysis.NotNullAttribute; | ||
System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute; | ||
System.Diagnostics.CodeAnalysis.NotNullWhenAttribute; | ||
System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute; | ||
System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute; | ||
System.Runtime.CompilerServices.CallerArgumentExpressionAttribute; | ||
System.Runtime.CompilerServices.IsExternalInit; | ||
System.Runtime.CompilerServices.SkipLocalsInitAttribute; | ||
</PolySharpIncludeGeneratedTypes> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Unity.Abstractions" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ReflectionEventing\ReflectionEventing.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,25 @@ | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT. | ||
// Copyright (C) Leszek Pomianowski and ReflectionEventing Contributors. | ||
// All Rights Reserved. | ||
|
||
using Unity; | ||
|
||
namespace ReflectionEventing.Unity; | ||
|
||
/// <summary> | ||
/// Provides event consumers for Unity. | ||
/// </summary> | ||
public class UnityConsumerProvider(IUnityContainer container) : IConsumerProvider | ||
{ | ||
/// <inheritdoc /> | ||
public IEnumerable<object> GetConsumerTypes(Type consumerType) | ||
{ | ||
if (consumerType is null) | ||
{ | ||
throw new ArgumentNullException(nameof(consumerType)); | ||
} | ||
|
||
return container.ResolveAll(consumerType); | ||
} | ||
} |
Oops, something went wrong.