tuitio/IdentityServer.Application/Commands/Command.cs

46 lines
1.0 KiB
C#
Raw Normal View History

2020-12-20 03:06:43 +02:00
using MediatR;
using System;
using System.Collections.Generic;
namespace IdentityServer.Application.Commands
{
public abstract class Command<TResponse> : ICommand, IRequest<TResponse>
{
public Metadata Metadata { get; }
protected Command()
{
Metadata = new Metadata() { CorrelationId = Guid.NewGuid() };
}
protected Command(Metadata metadata)
{
Metadata = metadata;
}
}
public interface ICommand
{
}
public class Metadata : Dictionary<string, string>
{
public const string CorrelationIdKey = "CorrelationId";
public Guid CorrelationId
{
get
{
return Guid.Parse(this[CorrelationIdKey]);
}
set
{
if (ContainsKey(CorrelationIdKey))
this[CorrelationIdKey] = value.ToString();
else
Add(CorrelationIdKey, value.ToString());
}
}
}
}