Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,19 @@ bin
*.user
*.gpState
TestResults
[Bb]inaries
[Bb]inaries

# Visual Studio 2015 cache/options directory
.vs/

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
115 changes: 115 additions & 0 deletions src/SimpleCQRS.NetStandard.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{BE8A5F95-23AD-4B5D-BA21-004909E80F00}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EF3C709C-758C-451D-8B6C-4222D1BE8EDF}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
Local.testsettings = Local.testsettings
Simple CQRS.vsmdi = Simple CQRS.vsmdi
TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventStores", "EventStores", "{77CC485D-D260-45FC-A161-3DDF3A571C41}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.EventStore.MongoDb", "EventStores\SimpleCqrs.EventStore.MongoDb\SimpleCqrs.EventStore.MongoDb.csproj", "{201A4DF5-2217-4202-80E8-E784737366BC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventStores", "EventStores", "{D3DFE07B-B78C-4AF2-A886-002A09D9FAA0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCrqs.EventStore.MongoDb.Tests", "Tests\EventStores\SimpleCrqs.EventStore.MongoDb.Tests\SimpleCrqs.EventStore.MongoDb.Tests.csproj", "{38E51E8F-7008-47EC-AC9F-862A1F377532}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ServiceLocators", "ServiceLocators", "{0C8AE82D-CACF-44CD-BE4F-222041AC4699}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.Unity", "ServiceLocators\SimpleCqrs.Unity\SimpleCqrs.Unity.csproj", "{00634E6C-A282-404A-B08B-338FD4CA41A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.EventStore.File", "EventStores\SimpleCqrs.EventStore.File\SimpleCqrs.EventStore.File.csproj", "{65B52205-E45D-4D6B-8F48-AFBC4406BEE8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{51C20E77-8726-49E8-9061-161DF28973E7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.NServiceBus", "Extensions\SimpleCqrs.NServiceBus.Core\SimpleCqrs.NServiceBus.csproj", "{07C2BF77-9646-4C39-BDB2-852B76AA6C75}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.Utilites", "SimpleCqrs.Utilites\SimpleCqrs.Utilites.csproj", "{266DAB4E-3EAD-46A5-88D5-0D9B6EC73A86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.Rhino.ServiceBus", "Extensions\SimpleCqrs.Rhino.ServiceBus\SimpleCqrs.Rhino.ServiceBus.csproj", "{EE1B7085-F7BC-48BD-B058-C33DF4CD0F74}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.EventStore.SqlServer", "EventStores\SimpleCqrs.EventStore.SqlServer\SimpleCqrs.EventStore.SqlServer.csproj", "{BEEBFC8E-91EC-4E24-8223-395C2302C1B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.StructureMap", "ServiceLocators\SimpleCqrs.StructureMap\SimpleCqrs.StructureMap.csproj", "{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SimpleCqrs", "SimpleCqrs\SimpleCqrs.xproj", "{E5F6DA96-FC56-42E1-BCEA-816D482711B4}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SimpleCqrs.Tests", "Tests\SimpleCqrs.Tests\SimpleCqrs.Tests.xproj", "{C79D813B-46A6-4CA6-B09F-796C183101F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{201A4DF5-2217-4202-80E8-E784737366BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{201A4DF5-2217-4202-80E8-E784737366BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{201A4DF5-2217-4202-80E8-E784737366BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{201A4DF5-2217-4202-80E8-E784737366BC}.Release|Any CPU.Build.0 = Release|Any CPU
{38E51E8F-7008-47EC-AC9F-862A1F377532}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{38E51E8F-7008-47EC-AC9F-862A1F377532}.Debug|Any CPU.Build.0 = Debug|Any CPU
{38E51E8F-7008-47EC-AC9F-862A1F377532}.Release|Any CPU.ActiveCfg = Release|Any CPU
{38E51E8F-7008-47EC-AC9F-862A1F377532}.Release|Any CPU.Build.0 = Release|Any CPU
{00634E6C-A282-404A-B08B-338FD4CA41A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00634E6C-A282-404A-B08B-338FD4CA41A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00634E6C-A282-404A-B08B-338FD4CA41A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00634E6C-A282-404A-B08B-338FD4CA41A9}.Release|Any CPU.Build.0 = Release|Any CPU
{65B52205-E45D-4D6B-8F48-AFBC4406BEE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65B52205-E45D-4D6B-8F48-AFBC4406BEE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65B52205-E45D-4D6B-8F48-AFBC4406BEE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65B52205-E45D-4D6B-8F48-AFBC4406BEE8}.Release|Any CPU.Build.0 = Release|Any CPU
{07C2BF77-9646-4C39-BDB2-852B76AA6C75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07C2BF77-9646-4C39-BDB2-852B76AA6C75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07C2BF77-9646-4C39-BDB2-852B76AA6C75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07C2BF77-9646-4C39-BDB2-852B76AA6C75}.Release|Any CPU.Build.0 = Release|Any CPU
{266DAB4E-3EAD-46A5-88D5-0D9B6EC73A86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{266DAB4E-3EAD-46A5-88D5-0D9B6EC73A86}.Debug|Any CPU.Build.0 = Debug|Any CPU
{266DAB4E-3EAD-46A5-88D5-0D9B6EC73A86}.Release|Any CPU.ActiveCfg = Release|Any CPU
{266DAB4E-3EAD-46A5-88D5-0D9B6EC73A86}.Release|Any CPU.Build.0 = Release|Any CPU
{EE1B7085-F7BC-48BD-B058-C33DF4CD0F74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE1B7085-F7BC-48BD-B058-C33DF4CD0F74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE1B7085-F7BC-48BD-B058-C33DF4CD0F74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE1B7085-F7BC-48BD-B058-C33DF4CD0F74}.Release|Any CPU.Build.0 = Release|Any CPU
{BEEBFC8E-91EC-4E24-8223-395C2302C1B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BEEBFC8E-91EC-4E24-8223-395C2302C1B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEEBFC8E-91EC-4E24-8223-395C2302C1B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEEBFC8E-91EC-4E24-8223-395C2302C1B3}.Release|Any CPU.Build.0 = Release|Any CPU
{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98}.Release|Any CPU.Build.0 = Release|Any CPU
{E5F6DA96-FC56-42E1-BCEA-816D482711B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5F6DA96-FC56-42E1-BCEA-816D482711B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5F6DA96-FC56-42E1-BCEA-816D482711B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5F6DA96-FC56-42E1-BCEA-816D482711B4}.Release|Any CPU.Build.0 = Release|Any CPU
{C79D813B-46A6-4CA6-B09F-796C183101F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C79D813B-46A6-4CA6-B09F-796C183101F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C79D813B-46A6-4CA6-B09F-796C183101F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C79D813B-46A6-4CA6-B09F-796C183101F5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{201A4DF5-2217-4202-80E8-E784737366BC} = {77CC485D-D260-45FC-A161-3DDF3A571C41}
{D3DFE07B-B78C-4AF2-A886-002A09D9FAA0} = {BE8A5F95-23AD-4B5D-BA21-004909E80F00}
{38E51E8F-7008-47EC-AC9F-862A1F377532} = {D3DFE07B-B78C-4AF2-A886-002A09D9FAA0}
{00634E6C-A282-404A-B08B-338FD4CA41A9} = {0C8AE82D-CACF-44CD-BE4F-222041AC4699}
{65B52205-E45D-4D6B-8F48-AFBC4406BEE8} = {77CC485D-D260-45FC-A161-3DDF3A571C41}
{07C2BF77-9646-4C39-BDB2-852B76AA6C75} = {51C20E77-8726-49E8-9061-161DF28973E7}
{EE1B7085-F7BC-48BD-B058-C33DF4CD0F74} = {51C20E77-8726-49E8-9061-161DF28973E7}
{BEEBFC8E-91EC-4E24-8223-395C2302C1B3} = {77CC485D-D260-45FC-A161-3DDF3A571C41}
{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98} = {0C8AE82D-CACF-44CD-BE4F-222041AC4699}
{C79D813B-46A6-4CA6-B09F-796C183101F5} = {BE8A5F95-23AD-4B5D-BA21-004909E80F00}
EndGlobalSection
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = Simple CQRS.vsmdi
EndGlobalSection
EndGlobal
34 changes: 18 additions & 16 deletions src/SimpleCQRS.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{BE8A5F95-23AD-4B5D-BA21-004909E80F00}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EF3C709C-758C-451D-8B6C-4222D1BE8EDF}"
Expand All @@ -10,8 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.Tests", "Tests\SimpleCqrs.Tests\SimpleCqrs.Tests.csproj", "{6AEAEE90-CF43-47CE-BD60-9F9519120BC6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EventStores", "EventStores", "{77CC485D-D260-45FC-A161-3DDF3A571C41}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.EventStore.MongoDb", "EventStores\SimpleCqrs.EventStore.MongoDb\SimpleCqrs.EventStore.MongoDb.csproj", "{201A4DF5-2217-4202-80E8-E784737366BC}"
Expand Down Expand Up @@ -40,19 +40,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.EventStore.SqlSe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleCqrs.StructureMap", "ServiceLocators\SimpleCqrs.StructureMap\SimpleCqrs.StructureMap.csproj", "{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SimpleCqrs.Tests", "Tests\SimpleCqrs.Tests\SimpleCqrs.Tests.xproj", "{C79D813B-46A6-4CA6-B09F-796C183101F5}"
EndProject
Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = Simple CQRS.vsmdi
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6AEAEE90-CF43-47CE-BD60-9F9519120BC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AEAEE90-CF43-47CE-BD60-9F9519120BC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AEAEE90-CF43-47CE-BD60-9F9519120BC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AEAEE90-CF43-47CE-BD60-9F9519120BC6}.Release|Any CPU.Build.0 = Release|Any CPU
{201A4DF5-2217-4202-80E8-E784737366BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{201A4DF5-2217-4202-80E8-E784737366BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{201A4DF5-2217-4202-80E8-E784737366BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -93,20 +88,27 @@ Global
{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98}.Release|Any CPU.Build.0 = Release|Any CPU
{C79D813B-46A6-4CA6-B09F-796C183101F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C79D813B-46A6-4CA6-B09F-796C183101F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C79D813B-46A6-4CA6-B09F-796C183101F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C79D813B-46A6-4CA6-B09F-796C183101F5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6AEAEE90-CF43-47CE-BD60-9F9519120BC6} = {BE8A5F95-23AD-4B5D-BA21-004909E80F00}
{D3DFE07B-B78C-4AF2-A886-002A09D9FAA0} = {BE8A5F95-23AD-4B5D-BA21-004909E80F00}
{201A4DF5-2217-4202-80E8-E784737366BC} = {77CC485D-D260-45FC-A161-3DDF3A571C41}
{65B52205-E45D-4D6B-8F48-AFBC4406BEE8} = {77CC485D-D260-45FC-A161-3DDF3A571C41}
{BEEBFC8E-91EC-4E24-8223-395C2302C1B3} = {77CC485D-D260-45FC-A161-3DDF3A571C41}
{D3DFE07B-B78C-4AF2-A886-002A09D9FAA0} = {BE8A5F95-23AD-4B5D-BA21-004909E80F00}
{38E51E8F-7008-47EC-AC9F-862A1F377532} = {D3DFE07B-B78C-4AF2-A886-002A09D9FAA0}
{00634E6C-A282-404A-B08B-338FD4CA41A9} = {0C8AE82D-CACF-44CD-BE4F-222041AC4699}
{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98} = {0C8AE82D-CACF-44CD-BE4F-222041AC4699}
{65B52205-E45D-4D6B-8F48-AFBC4406BEE8} = {77CC485D-D260-45FC-A161-3DDF3A571C41}
{07C2BF77-9646-4C39-BDB2-852B76AA6C75} = {51C20E77-8726-49E8-9061-161DF28973E7}
{EE1B7085-F7BC-48BD-B058-C33DF4CD0F74} = {51C20E77-8726-49E8-9061-161DF28973E7}
{BEEBFC8E-91EC-4E24-8223-395C2302C1B3} = {77CC485D-D260-45FC-A161-3DDF3A571C41}
{9C1063E4-1A0B-4402-8D78-A3F8E23D3D98} = {0C8AE82D-CACF-44CD-BE4F-222041AC4699}
{C79D813B-46A6-4CA6-B09F-796C183101F5} = {BE8A5F95-23AD-4B5D-BA21-004909E80F00}
EndGlobalSection
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = Simple CQRS.vsmdi
EndGlobalSection
EndGlobal
15 changes: 15 additions & 0 deletions src/SimpleCqrs/AssemblyTypeCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,34 @@ public Type[] GetDerivedTypes<T>()

public Type[] GetGenericInterfaceImplementations(Type type)
{
#if NETSTANDARD
return (from derivedType in loadedTypes
from interfaceType in derivedType.GetInterfaces()
where interfaceType.GetTypeInfo().IsGenericType && interfaceType.GetGenericTypeDefinition() == type
select derivedType).Distinct().ToArray();
#else
return (from derivedType in loadedTypes
from interfaceType in derivedType.GetInterfaces()
where interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == type
select derivedType).Distinct().ToArray();
#endif
}

public Type[] GetInterfaceImplementations(Type type)
{
#if NETSTANDARD
return (from derivedType in loadedTypes
where !derivedType.GetTypeInfo().IsInterface
from interfaceType in derivedType.GetInterfaces()
where interfaceType == type
select derivedType).Distinct().ToArray();
#else
return (from derivedType in loadedTypes
where !derivedType.IsInterface
from interfaceType in derivedType.GetInterfaces()
where interfaceType == type
select derivedType).Distinct().ToArray();
#endif
}

public Type[] GetInterfaceImplementations<T>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
#if NETSTANDARD
using System.Diagnostics;
using System.Reflection;
#endif

namespace SimpleCqrs.Commanding
{
Expand Down Expand Up @@ -40,11 +44,19 @@ private static IEnumerable<Type> GetAllCommandHandlerTypes(ITypeCatalog typeCata

private static IEnumerable<Type> GetCommandTypesForCommandHandler(Type commandHandlerType)
{
#if NETSTANDARD
return (from interfaceType in commandHandlerType.GetInterfaces()
where
interfaceType.GetTypeInfo().IsGenericType &&
interfaceType.GetGenericTypeDefinition() == typeof(IHandleCommands<>)
select interfaceType.GetGenericArguments()[0]).ToArray();
#else
return (from interfaceType in commandHandlerType.GetInterfaces()
where
interfaceType.IsGenericType &&
interfaceType.GetGenericTypeDefinition() == typeof (IHandleCommands<>)
interfaceType.GetGenericTypeDefinition() == typeof(IHandleCommands<>)
select interfaceType.GetGenericArguments()[0]).ToArray();
#endif
}
}
}
}
}
2 changes: 2 additions & 0 deletions src/SimpleCqrs/Commanding/ExecuteTimeoutException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public ExecuteTimeoutException(string message, Exception inner) : base(message,
{
}

#if ! NETSTANDARD
protected ExecuteTimeoutException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
#endif
}
}
16 changes: 11 additions & 5 deletions src/SimpleCqrs/Domain/AggregateRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,17 @@ private void ApplyEventToInternalState(DomainEvent domainEvent)
var aggregateRootType = GetType();

var eventHandlerMethodName = GetEventHandlerMethodName(domainEventTypeName);
var methodInfo = aggregateRootType.GetMethod(eventHandlerMethodName,
BindingFlags.Instance | BindingFlags.Public |
BindingFlags.NonPublic, null, new[] {domainEventType}, null);

if(methodInfo != null && EventHandlerMethodInfoHasCorrectParameter(methodInfo, domainEventType))
#if NETSTANDARD
var methodInfo = aggregateRootType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.FirstOrDefault(f => f.Name == eventHandlerMethodName
&& !f.GetParameters().Any(a => a.ParameterType != domainEventType));
#else
var methodInfo = aggregateRootType.GetMethod(eventHandlerMethodName,
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
null, new[] { domainEventType }, null);
#endif

if (methodInfo != null && EventHandlerMethodInfoHasCorrectParameter(methodInfo, domainEventType))
{
methodInfo.Invoke(this, new[] {domainEvent});
}
Expand Down
12 changes: 9 additions & 3 deletions src/SimpleCqrs/Domain/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ private void ApplyEventToInternalState(EntityDomainEvent domainEvent)
var domainEventTypeName = domainEventType.Name;
var entityType = GetType();

#if NETSTANDARD
var methodInfo = entityType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.FirstOrDefault(f => f.Name == GetEventHandlerMethodName(domainEventTypeName)
&& !f.GetParameters().Any(a => a.ParameterType != domainEventType));
#else
var methodInfo = entityType.GetMethod(GetEventHandlerMethodName(domainEventTypeName),
BindingFlags.Instance | BindingFlags.Public |
BindingFlags.NonPublic, null, new[] {domainEventType}, null);
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
null, new[] {domainEventType}, null);
#endif

if(methodInfo == null || !EventHandlerMethodInfoHasCorrectParameter(methodInfo, domainEventType)) return;
if (methodInfo == null || !EventHandlerMethodInfoHasCorrectParameter(methodInfo, domainEventType)) return;

methodInfo.Invoke(this, new[] {domainEvent});
}
Expand Down
Loading