-
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
Showing
230 changed files
with
8,568 additions
and
488 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "lib/AspNetCore.Hashids"] | ||
path = lib/AspNetCore.Hashids | ||
url = https://github.com/dgmjr/AspNetCore.Hashids.git | ||
[submodule "src/Http/CorrelationId"] | ||
path = src/Http/CorrelationId | ||
url = https://github.com/dgmjr-io/CorrelationId.git |
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,25 @@ | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
builder.Services.AddRazorPages(); | ||
|
||
var app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
if (!app.Environment.IsDevelopment()) | ||
{ | ||
app.UseExceptionHandler("/Error"); | ||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. | ||
app.UseHsts(); | ||
} | ||
|
||
app.UseHttpsRedirection(); | ||
app.UseStaticFiles(); | ||
|
||
app.UseRouting(); | ||
|
||
app.UseAuthorization(); | ||
|
||
app.MapRazorPages(); | ||
|
||
app.Run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
date: 2023-07-13T05:44:46:00-05:00Z | ||
description: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, yadda, yadda, yadda... | ||
keywords: | ||
- IP | ||
- copyright | ||
- license | ||
- mit | ||
permissions: | ||
- commercial-use | ||
- modifications | ||
- distribution | ||
- private-use | ||
conditions: | ||
- include-copyright | ||
limitations: | ||
- liability | ||
- warranty | ||
lastmod: 2024-01-0T00:39:00.0000+05:00Z | ||
license: MIT | ||
slug: mit-license | ||
title: MIT License | ||
type: license | ||
--- | ||
|
||
# MIT License | ||
|
||
## Copyright © 2022-2024 [David G. Moore, Jr.](mailto:[email protected] "Send Dr. Moore") ([@dgmjr](https://github.com/dgmjr "Contact Dr. Moore on GitHub")), All Rights Reserved | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions
124
src/Communication/AzureCommunicationServicesAutoConfigurator.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,124 @@ | ||
/* | ||
* AutoConfigurator.cs | ||
* | ||
* Created: 2024-17-19T08:17:28-05:00 | ||
* Modified: 2024-17-19T08:17:28-05:00 | ||
* | ||
* Author: David G. Moore, Jr. <[email protected]> | ||
* | ||
* Copyright © 2024 David G. Moore, Jr., All Rights Reserved | ||
* License: MIT (https://opensource.org/licenses/MIT) | ||
*/ | ||
|
||
namespace Microsoft.Extensions.DependencyInjection; | ||
|
||
using Dgmjr.AspNetCore.Communication; | ||
using Dgmjr.AspNetCore.Communication.Email; | ||
using Dgmjr.AspNetCore.Communication.Sms; | ||
|
||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
public class AzureCommunicationServicesAutoConfigurator( | ||
ILogger<AzureCommunicationServicesAutoConfigurator> logger | ||
) : IConfigureIHostApplicationBuilder, IConfigureIApplicationBuilder, ILog | ||
{ | ||
public ConfigurationOrder Order => ConfigurationOrder.AnyTime; | ||
|
||
public ILogger Logger => logger; | ||
|
||
public void Configure(IApplicationBuilder builder) | ||
{ | ||
var emailSenderOptions = builder.ApplicationServices.GetService< | ||
IOptions<EmailSenderOptions> | ||
>(); | ||
if (emailSenderOptions is null) | ||
{ | ||
Logger.LogWarning( | ||
"Azure Email Communication Services options are not configured. Please configure them in your appsettings.json file." | ||
); | ||
} | ||
var smsSenderOptions = builder.ApplicationServices.GetService<IOptions<SmsSenderOptions>>(); | ||
if (smsSenderOptions is null) | ||
{ | ||
Logger.LogWarning( | ||
"Azure SMS Communication Services options are not configured. Please configure them in your appsettings.json file." | ||
); | ||
} | ||
} | ||
|
||
public void Configure(IHostApplicationBuilder builder) | ||
{ | ||
var optionsSection = builder.Configuration.GetSection( | ||
AzureCommunicationServicesOptionsBase.ConfigurationSectionName | ||
); | ||
if (!optionsSection.Exists()) | ||
{ | ||
Logger.LogWarning( | ||
"Azure Communication Services options are not configured. Please configure them in your appsettings.json file." | ||
); | ||
} | ||
else | ||
{ | ||
builder.Services.Configure<AzureCommunicationServicesOptions>(optionsSection); | ||
|
||
var emailCommunicationSection = builder.Configuration.GetSection( | ||
EmailSenderOptions.ConfigurationSectionName | ||
); | ||
if (!emailCommunicationSection.Exists()) | ||
{ | ||
Logger.LogWarning( | ||
"Azure Email Communication Services options are not configured. Please configure them in your appsettings.json file." | ||
); | ||
builder.Services.AddSingleton<IEmailSender>( | ||
y => | ||
throw new KeyNotFoundException( | ||
$"The {nameof(EmailSenderOptions)} configuration section was not found in the appsettings.json file." | ||
) | ||
); | ||
} | ||
else | ||
{ | ||
builder.Services.Configure<EmailSenderOptions>(emailCommunicationSection); | ||
builder.Services.AddSingleton<IEmailSender>( | ||
y => | ||
new EmailSender( | ||
y.GetService<IOptions<EmailSenderOptions>>() | ||
?? throw new KeyNotFoundException( | ||
$"The {nameof(EmailSenderOptions)} configuration section was not found in the appsettings.json file." | ||
) | ||
) | ||
); | ||
} | ||
var smsCommunicationSection = builder.Configuration.GetSection( | ||
SmsSenderOptions.ConfigurationSectionName | ||
); | ||
if (!smsCommunicationSection.Exists()) | ||
{ | ||
Logger.LogWarning( | ||
"Azure SMS Communication Services options are not configured. Please configure them in your appsettings.json file." | ||
); | ||
builder.Services.AddSingleton<ISmsSender>( | ||
y => | ||
throw new KeyNotFoundException( | ||
$"The {nameof(SmsSenderOptions)} configuration section was not found in the appsettings.json file." | ||
) | ||
); | ||
} | ||
else | ||
{ | ||
builder.Services.Configure<SmsSenderOptions>(smsCommunicationSection); | ||
builder.Services.AddSingleton<ISmsSender>( | ||
y => | ||
new SmsSender( | ||
y.GetService<IOptions<SmsSenderOptions>>() | ||
?? throw new KeyNotFoundException( | ||
$"The {nameof(SmsSenderOptions)} configuration section was not found in the appsettings.json file." | ||
) | ||
) | ||
); | ||
} | ||
} | ||
} | ||
} |
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.