-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bringing back AspNetResult attribute
- Loading branch information
Showing
4 changed files
with
45 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Aksio Insurtech. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.AspNetCore.Mvc.Filters; | ||
|
||
namespace Aksio.Applications; | ||
|
||
/// <summary> | ||
/// Represents an attribute that indicates that the result of actions in a controller should be returned as an ASP.NET result. | ||
/// </summary> | ||
/// <remarks> | ||
/// Can be used for an entire controller or individual actions. | ||
/// </remarks> | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] | ||
public sealed class AspNetResultAttribute : Attribute, IFilterMetadata | ||
{ | ||
} |
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,20 @@ | ||
// Copyright (c) Aksio Insurtech. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Aksio.Applications; | ||
|
||
namespace Microsoft.AspNetCore.Mvc.Filters; | ||
|
||
/// <summary> | ||
/// Extensions for <see cref="ActionExecutingContext"/>. | ||
/// </summary> | ||
public static class AspNetResultExtensions | ||
{ | ||
/// <summary> | ||
/// Check if an action has the with <see cref="AspNetResultAttribute"/> as filter. | ||
/// </summary> | ||
/// <param name="context"><see cref="ActionExecutingContext"/> to check.</param> | ||
/// <returns>True if it has, false if not.</returns> | ||
public static bool IsAspNetResult(this ActionExecutingContext context) | ||
=> context.Filters.Any(_ => _ is AspNetResultAttribute); | ||
} |
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