@ -1,8 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>netstandard1.4</TargetFramework> | |||||
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.CommandBus</RootNamespace> | |||||
</PropertyGroup> | |||||
</Project> |
@ -1,13 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.CommandBus | |||||
{ | |||||
public interface ICommandBus | |||||
{ | |||||
Task SendAsync<T>(T command) where T : IntegrationCommand; | |||||
} | |||||
} |
@ -1,18 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.CommandBus | |||||
{ | |||||
public abstract class IntegrationCommand | |||||
{ | |||||
public Guid Id { get; private set; } | |||||
public DateTime Sent { get; private set; } | |||||
protected IntegrationCommand() | |||||
{ | |||||
Id = Guid.NewGuid(); | |||||
Sent = DateTime.UtcNow; | |||||
} | |||||
} | |||||
} |
@ -1,7 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>netstandard1.4</TargetFramework> | |||||
</PropertyGroup> | |||||
</Project> |
@ -1,8 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>netstandard1.0</TargetFramework> | |||||
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.CommandBus</RootNamespace> | |||||
</PropertyGroup> | |||||
</Project> |
@ -1,16 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.CommandBus | |||||
{ | |||||
public interface ICommandBus | |||||
{ | |||||
void Send<T>(string name, T data); | |||||
void Handle<TC>(string name, IIntegrationCommandHandler<TC> handler); | |||||
void Handle(string name, IIntegrationCommandHandler handler); | |||||
void Handle<TI, TC>(TI handler) | |||||
where TI : IIntegrationCommandHandler<TC>; | |||||
} | |||||
} |
@ -1,16 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.CommandBus | |||||
{ | |||||
public interface IIntegrationCommandHandler | |||||
{ | |||||
void Handle(IntegrationCommand command); | |||||
} | |||||
public interface IIntegrationCommandHandler<T> : IIntegrationCommandHandler | |||||
{ | |||||
void Handle(IntegrationCommand<T> command); | |||||
} | |||||
} |
@ -1,35 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.CommandBus | |||||
{ | |||||
public abstract class IntegrationCommand | |||||
{ | |||||
public Guid Id { get; } | |||||
public DateTime Sent { get; } | |||||
public abstract object GetDataAsObject(); | |||||
protected IntegrationCommand() | |||||
{ | |||||
Id = Guid.NewGuid(); | |||||
Sent = DateTime.UtcNow; | |||||
} | |||||
} | |||||
public class IntegrationCommand<T> : IntegrationCommand | |||||
{ | |||||
public T Data { get; } | |||||
public string Name { get; } | |||||
public override object GetDataAsObject() => Data; | |||||
public IntegrationCommand(string name, T data) : base() | |||||
{ | |||||
Data = data; | |||||
Name = name; | |||||
} | |||||
} | |||||
} |