-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid exposing the method called ConfigureWebApplicationBuilder to th…
…e plugins * Replace the PluginStartup interface with IDependencyServicesRegisterer (it is a more descriptive name) * Replace the ConfigureWebApplicationBuilder method with RegisterServices(IServiceCollection, IConfiguration). The consumer should not be able to use the type called WebApplicationBuilder in its plugins, because it has the absolute freedom to build the web application through the Build() method and this does not make sense, since it is the responsibility of the host application.
- Loading branch information
1 parent
aa77129
commit b879c7a
Showing
12 changed files
with
72 additions
and
63 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
11 changes: 11 additions & 0 deletions
11
src/Plugins/AppointmentReminders/DependencyServicesRegisterer.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,11 @@ | ||
[assembly: Plugin(typeof(DependencyServicesRegisterer))] | ||
|
||
namespace Plugin.AppointmentReminders; | ||
|
||
public class DependencyServicesRegisterer : IDependencyServicesRegisterer | ||
{ | ||
public void RegisterServices(IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddReminderServices(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[assembly: Plugin(typeof(DependencyServicesRegisterer))] | ||
|
||
namespace Plugin.ChatBot; | ||
|
||
public class DependencyServicesRegisterer : IDependencyServicesRegisterer | ||
{ | ||
public void RegisterServices(IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddBotServices(configuration); | ||
} | ||
} |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[assembly: Plugin(typeof(DependencyServicesRegisterer))] | ||
|
||
namespace Plugin.SendGrid; | ||
|
||
public class DependencyServicesRegisterer : IDependencyServicesRegisterer | ||
{ | ||
public void RegisterServices(IServiceCollection services, IConfiguration configuration) | ||
{ | ||
var settings = new EnvBinder().Bind<SendGridSettings>(); | ||
services.AddSendGrid(options => options.ApiKey = settings.SendGridApiKey); | ||
services.AddScoped<IEmailService, EmailService>(); | ||
services.AddSingleton(settings); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/Plugins/TwilioWhatsApp/DependencyServicesRegisterer.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,13 @@ | ||
[assembly: Plugin(typeof(DependencyServicesRegisterer))] | ||
|
||
namespace Plugin.Twilio.WhatsApp; | ||
|
||
public class DependencyServicesRegisterer : IDependencyServicesRegisterer | ||
{ | ||
public void RegisterServices(IServiceCollection services, IConfiguration configuration) | ||
{ | ||
var settings = new EnvBinder().Bind<TwilioSettings>(); | ||
services.AddSingleton<IInstantMessaging, WhatsAppMessaging>(); | ||
services.AddSingleton(settings); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace DentallApp.Shared.Interfaces; | ||
|
||
/// <summary> | ||
/// Base type for initializing services used by a plugin. | ||
/// </summary> | ||
public interface IDependencyServicesRegisterer | ||
{ | ||
/// <summary> | ||
/// Register services into the <see cref="IServiceCollection"/>. | ||
/// </summary> | ||
/// <param name="services"> | ||
/// The <see cref="IServiceCollection"/> to add the services to. | ||
/// </param> | ||
/// <param name="configuration"> | ||
/// The set of key/value configuration properties. | ||
/// </param> | ||
void RegisterServices(IServiceCollection services, IConfiguration configuration); | ||
} |
This file was deleted.
Oops, something went wrong.