增加Mediat Pip特性,并用实例来做一个demo
This commit is contained in:
1 parent
292cb8638c
commit
c9ac7412ab
19 files changed
+682
-108
No files matched your search
@@ -0,0 +1,7 @@
|
||||
namespace MAX.Core.Mediation;
|
||||
|
||||
/// <summary>提供请求自身的参数校验;不合法时抛出 ValidationException。</summary>
|
||||
public interface IValidatableRequest
|
||||
{
|
||||
void Validate();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Adapted from ITIXO/MediatR.Extensions.AttributedBehaviors (MIT).
|
||||
// Copyright (c) 2021 ITIXO s.r.o. See ThirdPartyNotices/MediatR.Extensions.AttributedBehaviors.LICENSE.txt.
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace MAX.Core.Mediation;
|
||||
|
||||
/// <summary>声明命令管道。每个特性独占一行,按源码行号从上到下执行。</summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
|
||||
public sealed class MediatRBehaviorAttribute(Type behaviorType, [CallerLineNumber] int lineNumber = 0) : Attribute
|
||||
{
|
||||
public Type BehaviorType { get; } = behaviorType ?? throw new ArgumentNullException(nameof(behaviorType));
|
||||
public int LineNumber { get; } = lineNumber;
|
||||
}
|
||||
Reference in new issue
Block a user