-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.0.4 cached reflections + xml summaries
- Loading branch information
1 parent
595df77
commit c9fae42
Showing
12 changed files
with
191 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
src/Ogu.FluentValidation.AspNetCore.Attribute/Extensions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 10 additions & 4 deletions
14
src/Ogu.FluentValidation.AspNetCore.Attribute/InternalConstants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
using System; | ||
using FluentValidation; | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Threading; | ||
|
||
namespace Ogu.FluentValidation.AspNetCore.Attribute | ||
{ | ||
public static class InternalConstants | ||
internal static class InternalConstants | ||
{ | ||
public const string ValidateAsyncMethodName = "ValidateAsync"; | ||
public const string ValidateMethodName = "Validate"; | ||
internal const string ValidateAsyncMethodName = "ValidateAsync"; | ||
|
||
internal const string ValidateMethodName = "Validate"; | ||
|
||
internal static readonly Type CancellationTokenType = typeof(CancellationToken); | ||
|
||
internal static readonly Type IValidatorTType = typeof(IValidator<>); | ||
|
||
internal static readonly Type IInvalidValidationResponseType = typeof(IInvalidValidationResponse); | ||
|
||
internal static readonly Lazy<ConcurrentDictionary<string, bool>> ActionUuidToHasSkipValidateAttribute = new Lazy<ConcurrentDictionary<string, bool>>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Ogu.FluentValidation.AspNetCore.Attribute/ServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using FluentValidation.Results; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Ogu.FluentValidation.AspNetCore.Attribute; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
public static class ServiceCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Registers an implementation of <see cref="IInvalidValidationResponse"/> in the service collection. | ||
/// This method allows you to provide a custom response for validation failures. | ||
/// </summary> | ||
/// <param name="services">The service collection to which the implementation will be added.</param> | ||
/// <param name="invalidResponse"> | ||
/// A function that takes a list of <see cref="ValidationFailure"/> objects | ||
/// and returns an <see cref="IActionResult"/>. | ||
/// This function is invoked when validation failures occur. | ||
/// </param> | ||
/// <returns>The updated <see cref="IServiceCollection"/> with the registered implementation.</returns> | ||
/// <exception cref="ArgumentNullException"> | ||
/// Thrown when <paramref name="invalidResponse"/> is <c>null</c>. | ||
/// </exception> | ||
public static IServiceCollection AddInvalidValidationResponse(this IServiceCollection services, Func<List<ValidationFailure>, IActionResult> invalidResponse) | ||
{ | ||
invalidResponse = invalidResponse ?? throw new ArgumentNullException(nameof(invalidResponse)); | ||
|
||
services.AddSingleton<IInvalidValidationResponse>(new InvalidValidationResponse(invalidResponse)); | ||
|
||
return services; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.