NDB.Application.DataContracts
parent
9e4710e342
commit
a30ef66afc
|
@ -0,0 +1,24 @@
|
|||
using MediatR;
|
||||
using System;
|
||||
|
||||
namespace NDB.Application.DataContracts
|
||||
{
|
||||
public interface ICommand
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NDB.Application.DataContracts
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MediatR" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,6 @@
|
|||
using MediatR;
|
||||
|
||||
namespace NDB.Application.DataContracts
|
||||
{
|
||||
public abstract class Query<TResponse> : IRequest<TResponse>, IBaseRequest { }
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NDB.Extensions.Swagger.Filters
|
||||
{
|
||||
public class DtoSchemaFilter : ISchemaFilter
|
||||
{
|
||||
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
|
||||
{
|
||||
var targetType = context.Type;
|
||||
while (targetType != null)
|
||||
{
|
||||
if (typeof(ICommand).IsAssignableFrom(targetType))
|
||||
{
|
||||
foreach (var property in schema.Properties.ToList())
|
||||
{
|
||||
property.Value.ReadOnly = false;
|
||||
|
||||
switch (property.Key)
|
||||
{
|
||||
case "metadata":
|
||||
schema.Properties.Remove(property.Key);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targetType = targetType.DeclaringType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
NDB.sln
12
NDB.sln
|
@ -27,7 +27,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "extensions", "extensions",
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "swagger", "swagger", "{FB4E71FD-9E32-4B5C-8019-1E8EBB9DDE9F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDB.Extensions.Swagger", "NDB.Extensions.Swagger\NDB.Extensions.Swagger.csproj", "{CB9BDFCC-DB01-4A13-8091-9A241BE85CCD}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NDB.Extensions.Swagger", "NDB.Extensions.Swagger\NDB.Extensions.Swagger.csproj", "{CB9BDFCC-DB01-4A13-8091-9A241BE85CCD}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "application", "application", "{564B5266-6F7E-4AFA-A7D4-B0E8F2E7107E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDB.Application.DataContracts", "NDB.Application.DataContracts\NDB.Application.DataContracts.csproj", "{BDDC2DB1-96DD-49F4-BCEF-55D06B74E6F3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -59,6 +63,10 @@ Global
|
|||
{CB9BDFCC-DB01-4A13-8091-9A241BE85CCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CB9BDFCC-DB01-4A13-8091-9A241BE85CCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CB9BDFCC-DB01-4A13-8091-9A241BE85CCD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BDDC2DB1-96DD-49F4-BCEF-55D06B74E6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BDDC2DB1-96DD-49F4-BCEF-55D06B74E6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BDDC2DB1-96DD-49F4-BCEF-55D06B74E6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BDDC2DB1-96DD-49F4-BCEF-55D06B74E6F3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -67,6 +75,8 @@ Global
|
|||
{B50B55F0-9E6E-4061-9100-E2329A44E76B} = {E0202271-4E92-4DB8-900D-B5FD745B9278}
|
||||
{FB4E71FD-9E32-4B5C-8019-1E8EBB9DDE9F} = {B50B55F0-9E6E-4061-9100-E2329A44E76B}
|
||||
{CB9BDFCC-DB01-4A13-8091-9A241BE85CCD} = {FB4E71FD-9E32-4B5C-8019-1E8EBB9DDE9F}
|
||||
{564B5266-6F7E-4AFA-A7D4-B0E8F2E7107E} = {E0202271-4E92-4DB8-900D-B5FD745B9278}
|
||||
{BDDC2DB1-96DD-49F4-BCEF-55D06B74E6F3} = {564B5266-6F7E-4AFA-A7D4-B0E8F2E7107E}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {87541BAB-3FAC-4ADB-A7FB-8228DA87843D}
|
||||
|
|
Loading…
Reference in New Issue