Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #20 from osoykan/dev
Browse files Browse the repository at this point in the history
dev to master
  • Loading branch information
osoykan authored Mar 1, 2017
2 parents 7076ab8 + 35c27c9 commit 61e6005
Show file tree
Hide file tree
Showing 26 changed files with 212 additions and 93 deletions.
6 changes: 3 additions & 3 deletions src/Stove.Dapper/project.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": "0.0.10-*",
"version": "0.0.11-*",

"dependencies": {
"Autofac": "4.3.0",
"Dapper": "1.50.2",
"DapperExtensions": "1.5.0",
"EntityFramework": "6.1.3",
"Stove": "0.0.10",
"Stove.EntityFramework": "0.0.10-*"
"Stove": "0.0.11",
"Stove.EntityFramework": "0.0.11-*"
},

"frameworks": {
Expand Down
4 changes: 2 additions & 2 deletions src/Stove.EntityFramework/project.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version" : "0.0.10-*",
"version" : "0.0.11-*",

"dependencies": {
"Stove": "0.0.10",
"Stove": "0.0.11",
"EntityFramework": "6.1.3",
"EntityFramework.DynamicFilters": "2.6.0",
"System.Collections": "4.3.0",
Expand Down
4 changes: 2 additions & 2 deletions src/Stove.HangFire/project.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "0.0.10-*",
"version": "0.0.11-*",

"dependencies": {
"Stove": "0.0.10",
"Stove": "0.0.11",
"Hangfire": "1.6.8",
"Hangfire.Core": "1.6.8",
"Hangfire.SqlServer": "1.6.8",
Expand Down
4 changes: 2 additions & 2 deletions src/Stove.Mapster/project.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"version" : "0.0.10-*",
"version" : "0.0.11-*",

"dependencies" : {
"Mapster" : "2.6.1",
"Stove" : "0.0.10"
"Stove" : "0.0.11"
},

"frameworks" : {
Expand Down
4 changes: 2 additions & 2 deletions src/Stove.NLog/project.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"version" : "0.0.10-*",
"version" : "0.0.11-*",

"dependencies": {
"Autofac": "4.3.0",
"NLog": "4.4.3",
"Stove": "0.0.10"
"Stove": "0.0.11"
},

"frameworks" : {
Expand Down
4 changes: 2 additions & 2 deletions src/Stove.RabbitMQ/project.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"version": "0.0.10-*",
"version": "0.0.11-*",

"dependencies": {
"MassTransit": "3.5.5",
"MassTransit.Autofac": "3.5.5",
"MassTransit.RabbitMQ": "3.5.5",
"Stove": "0.0.10"
"Stove": "0.0.11"
},

"frameworks": {
Expand Down
4 changes: 2 additions & 2 deletions src/Stove.Redis/project.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"version" : "0.0.10-*",
"version" : "0.0.11-*",

"dependencies": {
"StackExchange.Redis": "1.2.1",
"StackExchange.Redis.Extensions.Core": "2.1.0",
"Stove": "0.0.10"
"Stove": "0.0.11"
},

"frameworks" : {
Expand Down
3 changes: 2 additions & 1 deletion src/Stove/Bootstrapping/StoveKernelBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;

using Autofac;
using Autofac.Extras.IocManager;

using Stove.BackgroundJobs;
Expand Down Expand Up @@ -68,7 +69,7 @@ private void ConfigureEventBus()
Type[] genericArgs = @interface.GetGenericArguments();
if (genericArgs.Length == 1)
{
_eventBus.Register(genericArgs[0], new IocHandlerFactory(Resolver.Resolve<IScopeResolver>().BeginScope(), impl));
_eventBus.Register(genericArgs[0], new IocHandlerFactory(Resolver.Resolve<IScopeResolver>(), impl));
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/Stove/Domain/Uow/UnitOfWorkManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Transactions;
using System.Linq;
using System.Transactions;

using Autofac.Extras.IocManager;

Expand Down Expand Up @@ -45,7 +46,9 @@ public IUnitOfWorkCompleteHandle Begin(UnitOfWorkOptions options)

options.FillDefaultsForNonProvidedOptions(_defaultOptions);

if (options.Scope == TransactionScopeOption.Required && _currentUnitOfWorkProvider.Current != null)
IUnitOfWork outerUow = _currentUnitOfWorkProvider.Current;

if (options.Scope == TransactionScopeOption.Required && outerUow != null)
{
return new InnerUnitOfWorkCompleteHandle();
}
Expand All @@ -58,6 +61,12 @@ public IUnitOfWorkCompleteHandle Begin(UnitOfWorkOptions options)

uow.Disposed += (sender, args) => { _childScope.Dispose(); };

//Inherit filters from outer UOW
if (outerUow != null)
{
options.FillOuterUowFiltersForNonProvidedOptions(outerUow.Filters.ToList());
}

uow.Begin(options);

_currentUnitOfWorkProvider.Current = uow;
Expand Down
14 changes: 14 additions & 0 deletions src/Stove/Domain/Uow/UnitOfWorkOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Transactions;

namespace Stove.Domain.Uow
Expand Down Expand Up @@ -75,5 +76,18 @@ internal void FillDefaultsForNonProvidedOptions(IUnitOfWorkDefaultOptions defaul
IsolationLevel = defaultOptions.IsolationLevel.Value;
}
}

internal void FillOuterUowFiltersForNonProvidedOptions(List<DataFilterConfiguration> filterOverrides)
{
foreach (var filterOverride in filterOverrides)
{
if (FilterOverrides.Any(fo => fo.FilterName == filterOverride.FilterName))
{
continue;
}

FilterOverrides.Add(filterOverride);
}
}
}
}
10 changes: 5 additions & 5 deletions src/Stove/Events/Bus/EventBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ namespace Stove.Events.Bus
/// </summary>
public class EventBus : IEventBus
{
/// <summary>
/// Gets the default <see cref="EventBus" /> instance.
/// </summary>
public static EventBus Default = new EventBus();

/// <summary>
/// All registered handler factories.
/// Key: Type of the event
Expand All @@ -38,11 +43,6 @@ public EventBus()
Logger = NullLogger.Instance;
}

/// <summary>
/// Gets the default <see cref="EventBus" /> instance.
/// </summary>
public static EventBus Default { get; } = new EventBus();

/// <summary>
/// Reference to the Logger.
/// </summary>
Expand Down
69 changes: 28 additions & 41 deletions src/Stove/Events/Bus/IEventBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,154 +7,144 @@
namespace Stove.Events.Bus
{
/// <summary>
/// Defines interface of the event bus.
/// Defines interface of the event bus.
/// </summary>
public interface IEventBus
{
#region Register

/// <summary>
/// Registers to an event.
/// Given action is called for all event occurrences.
/// Registers to an event.
/// Given action is called for all event occurrences.
/// </summary>
/// <param name="action">Action to handle events</param>
/// <typeparam name="TEventData">Event type</typeparam>
IDisposable Register<TEventData>(Action<TEventData> action) where TEventData : IEventData;

/// <summary>
/// Registers to an event.
/// Same (given) instance of the handler is used for all event occurrences.
/// Registers to an event.
/// Same (given) instance of the handler is used for all event occurrences.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="handler">Object to handle the event</param>
IDisposable Register<TEventData>(IEventHandler<TEventData> handler) where TEventData : IEventData;

/// <summary>
/// Registers to an event.
/// A new instance of <see cref="THandler"/> object is created for every event occurrence.
/// Registers to an event.
/// A new instance of <see cref="THandler" /> object is created for every event occurrence.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <typeparam name="THandler">Type of the event handler</typeparam>
IDisposable Register<TEventData, THandler>() where TEventData : IEventData where THandler : IEventHandler<TEventData>, new();

/// <summary>
/// Registers to an event.
/// Same (given) instance of the handler is used for all event occurrences.
/// Registers to an event.
/// Same (given) instance of the handler is used for all event occurrences.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="handler">Object to handle the event</param>
IDisposable Register(Type eventType, IEventHandler handler);

/// <summary>
/// Registers to an event.
/// Given factory is used to create/release handlers
/// Registers to an event.
/// Given factory is used to create/release handlers
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="handlerFactory">A factory to create/release handlers</param>
IDisposable Register<TEventData>(IEventHandlerFactory handlerFactory) where TEventData : IEventData;

/// <summary>
/// Registers to an event.
/// Registers to an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="handlerFactory">A factory to create/release handlers</param>
IDisposable Register(Type eventType, IEventHandlerFactory handlerFactory);

#endregion

#region Unregister

/// <summary>
/// Unregisters from an event.
/// Unregisters from an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="action"></param>
void Unregister<TEventData>(Action<TEventData> action) where TEventData : IEventData;

/// <summary>
/// Unregisters from an event.
/// Unregisters from an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="handler">Handler object that is registered before</param>
void Unregister<TEventData>(IEventHandler<TEventData> handler) where TEventData : IEventData;

/// <summary>
/// Unregisters from an event.
/// Unregisters from an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="handler">Handler object that is registered before</param>
void Unregister(Type eventType, IEventHandler handler);

/// <summary>
/// Unregisters from an event.
/// Unregisters from an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="factory">Factory object that is registered before</param>
void Unregister<TEventData>(IEventHandlerFactory factory) where TEventData : IEventData;

/// <summary>
/// Unregisters from an event.
/// Unregisters from an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="factory">Factory object that is registered before</param>
void Unregister(Type eventType, IEventHandlerFactory factory);

/// <summary>
/// Unregisters all event handlers of given event type.
/// Unregisters all event handlers of given event type.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
void UnregisterAll<TEventData>() where TEventData : IEventData;

/// <summary>
/// Unregisters all event handlers of given event type.
/// Unregisters all event handlers of given event type.
/// </summary>
/// <param name="eventType">Event type</param>
void UnregisterAll(Type eventType);

#endregion

#region Trigger

/// <summary>
/// Triggers an event.
/// Triggers an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="eventData">Related data for the event</param>
void Trigger<TEventData>(TEventData eventData) where TEventData : IEventData;

/// <summary>
/// Triggers an event.
/// Triggers an event.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="eventSource">The object which triggers the event</param>
/// <param name="eventData">Related data for the event</param>
void Trigger<TEventData>(object eventSource, TEventData eventData) where TEventData : IEventData;

/// <summary>
/// Triggers an event.
/// Triggers an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="eventData">Related data for the event</param>
void Trigger(Type eventType, IEventData eventData);

/// <summary>
/// Triggers an event.
/// Triggers an event.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="eventSource">The object which triggers the event</param>
/// <param name="eventData">Related data for the event</param>
void Trigger(Type eventType, object eventSource, IEventData eventData);

/// <summary>
/// Triggers an event asynchronously.
/// Triggers an event asynchronously.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="eventData">Related data for the event</param>
/// <returns>The task to handle async operation</returns>
Task TriggerAsync<TEventData>(TEventData eventData) where TEventData : IEventData;

/// <summary>
/// Triggers an event asynchronously.
/// Triggers an event asynchronously.
/// </summary>
/// <typeparam name="TEventData">Event type</typeparam>
/// <param name="eventSource">The object which triggers the event</param>
Expand All @@ -163,23 +153,20 @@ public interface IEventBus
Task TriggerAsync<TEventData>(object eventSource, TEventData eventData) where TEventData : IEventData;

/// <summary>
/// Triggers an event asynchronously.
/// Triggers an event asynchronously.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="eventData">Related data for the event</param>
/// <returns>The task to handle async operation</returns>
Task TriggerAsync(Type eventType, IEventData eventData);

/// <summary>
/// Triggers an event asynchronously.
/// Triggers an event asynchronously.
/// </summary>
/// <param name="eventType">Event type</param>
/// <param name="eventSource">The object which triggers the event</param>
/// <param name="eventData">Related data for the event</param>
/// <returns>The task to handle async operation</returns>
Task TriggerAsync(Type eventType, object eventSource, IEventData eventData);


#endregion
}
}
}
Loading

0 comments on commit 61e6005

Please sign in to comment.