-
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.
- Loading branch information
1 parent
5332fb3
commit 47a9c46
Showing
17 changed files
with
92 additions
and
109 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
9 changes: 2 additions & 7 deletions
9
ManagedCode.Communication.Extensions/Extensions/CommunicationAppBuilderExtensions.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,20 +1,15 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace ManagedCode.Communication.Extensions; | ||
namespace ManagedCode.Communication.Extensions.Extensions; | ||
|
||
public static class CommunicationAppBuilderExtensions | ||
{ | ||
public static IApplicationBuilder UseCommunication(this IApplicationBuilder app) | ||
{ | ||
if (app == null) | ||
{ | ||
throw new ArgumentNullException(nameof(app)); | ||
} | ||
|
||
|
||
return app.UseMiddleware<CommunicationMiddleware>(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
ManagedCode.Communication.Extensions/Extensions/CommunicationOptions.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,6 @@ | ||
namespace ManagedCode.Communication.Extensions.Extensions; | ||
|
||
public class CommunicationOptions | ||
{ | ||
public bool ShowErrorDetails { get; set; } = false; | ||
} |
10 changes: 6 additions & 4 deletions
10
ManagedCode.Communication.Extensions/Extensions/ControllerExtensions.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,17 +1,19 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace ManagedCode.Communication.Extensions; | ||
namespace ManagedCode.Communication.Extensions.Extensions; | ||
|
||
public static class ControllerExtensions | ||
{ | ||
public static IActionResult ToActionResult<T>(this Result<T> result) | ||
{ | ||
return result.IsSuccess ? new OkObjectResult(result.Value) : new BadRequestObjectResult(result.GetError()?.Message); | ||
return result.IsSuccess | ||
? new OkObjectResult(result.Value) | ||
: new BadRequestObjectResult(result.GetError()?.Message); | ||
} | ||
|
||
public static Microsoft.AspNetCore.Http.IResult ToHttpResult<T>(this Result<T> result) | ||
{ | ||
return result.IsSuccess ? Results.Ok(result.Value) : Results.BadRequest(result.GetError()?.Message); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
ManagedCode.Communication.Extensions/Extensions/HubOptionsExtensions.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
14 changes: 14 additions & 0 deletions
14
ManagedCode.Communication.Extensions/Extensions/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,14 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace ManagedCode.Communication.Extensions.Extensions; | ||
|
||
public static class ServiceCollectionExtensions | ||
{ | ||
public static IServiceCollection AddCommunication(this IServiceCollection services, | ||
Action<CommunicationOptions> options) | ||
{ | ||
services.AddOptions<CommunicationOptions>().Configure(options); | ||
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
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
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
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.