Moved namespaces to global usings for eventbus

This commit is contained in:
Sumit Ghosh 2021-10-13 12:51:44 +05:30
parent f847ec020f
commit f3d6492340
8 changed files with 245 additions and 280 deletions

View File

@ -1,9 +1,6 @@
using System.Threading.Tasks; namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions public interface IDynamicIntegrationEventHandler
{ {
public interface IDynamicIntegrationEventHandler
{
Task Handle(dynamic eventData); Task Handle(dynamic eventData);
}
} }

View File

@ -1,9 +1,7 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions public interface IEventBus
{ {
public interface IEventBus
{
void Publish(IntegrationEvent @event); void Publish(IntegrationEvent @event);
void Subscribe<T, TH>() void Subscribe<T, TH>()
@ -19,5 +17,4 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
void Unsubscribe<T, TH>() void Unsubscribe<T, TH>()
where TH : IIntegrationEventHandler<T> where TH : IIntegrationEventHandler<T>
where T : IntegrationEvent; where T : IntegrationEvent;
}
} }

View File

@ -1,15 +1,11 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions public interface IIntegrationEventHandler<in TIntegrationEvent> : IIntegrationEventHandler
{
public interface IIntegrationEventHandler<in TIntegrationEvent> : IIntegrationEventHandler
where TIntegrationEvent : IntegrationEvent where TIntegrationEvent : IntegrationEvent
{ {
Task Handle(TIntegrationEvent @event); Task Handle(TIntegrationEvent @event);
} }
public interface IIntegrationEventHandler public interface IIntegrationEventHandler
{ {
}
} }

View File

@ -1,10 +1,7 @@
using System; namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using System.Text.Json.Serialization;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events public record IntegrationEvent
{ {
public record IntegrationEvent
{
public IntegrationEvent() public IntegrationEvent()
{ {
Id = Guid.NewGuid(); Id = Guid.NewGuid();
@ -23,5 +20,4 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events
[JsonInclude] [JsonInclude]
public DateTime CreationDate { get; private init; } public DateTime CreationDate { get; private init; }
}
} }

View File

@ -1,10 +1,7 @@
using System; namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions;
using System.Linq;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions public static class GenericTypeExtensions
{ {
public static class GenericTypeExtensions
{
public static string GetGenericTypeName(this Type type) public static string GetGenericTypeName(this Type type)
{ {
var typeName = string.Empty; var typeName = string.Empty;
@ -26,5 +23,4 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions
{ {
return @object.GetType().GetGenericTypeName(); return @object.GetType().GetGenericTypeName();
} }
}
} }

View File

@ -1,13 +1,7 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using System;
using System.Collections.Generic;
using static Microsoft.eShopOnContainers.BuildingBlocks.EventBus.InMemoryEventBusSubscriptionsManager;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus public interface IEventBusSubscriptionsManager
{ {
public interface IEventBusSubscriptionsManager
{
bool IsEmpty { get; } bool IsEmpty { get; }
event EventHandler<string> OnEventRemoved; event EventHandler<string> OnEventRemoved;
void AddDynamicSubscription<TH>(string eventName) void AddDynamicSubscription<TH>(string eventName)
@ -30,5 +24,4 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
IEnumerable<SubscriptionInfo> GetHandlersForEvent<T>() where T : IntegrationEvent; IEnumerable<SubscriptionInfo> GetHandlersForEvent<T>() where T : IntegrationEvent;
IEnumerable<SubscriptionInfo> GetHandlersForEvent(string eventName); IEnumerable<SubscriptionInfo> GetHandlersForEvent(string eventName);
string GetEventKey<T>(); string GetEventKey<T>();
}
} }

View File

@ -1,13 +1,7 @@
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus public partial class InMemoryEventBusSubscriptionsManager : IEventBusSubscriptionsManager
{ {
public partial class InMemoryEventBusSubscriptionsManager : IEventBusSubscriptionsManager
{
private readonly Dictionary<string, List<SubscriptionInfo>> _handlers; private readonly Dictionary<string, List<SubscriptionInfo>> _handlers;
@ -158,5 +152,4 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
{ {
return typeof(T).Name; return typeof(T).Name;
} }
}
} }

View File

@ -1,9 +1,7 @@
using System; namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus public partial class InMemoryEventBusSubscriptionsManager : IEventBusSubscriptionsManager
{ {
public partial class InMemoryEventBusSubscriptionsManager : IEventBusSubscriptionsManager
{
public class SubscriptionInfo public class SubscriptionInfo
{ {
public bool IsDynamic { get; } public bool IsDynamic { get; }
@ -24,5 +22,4 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
return new SubscriptionInfo(false, handlerType); return new SubscriptionInfo(false, handlerType);
} }
} }
}
} }