46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
|
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());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|