diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Services/FacebookSettingsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Services/FacebookSettingsConfiguration.cs index a71b6ad59d5..7718627200a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Services/FacebookSettingsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Services/FacebookSettingsConfiguration.cs @@ -8,7 +8,7 @@ namespace OrchardCore.Facebook.Services; -public class FacebookSettingsConfiguration : IConfigureOptions +public class FacebookSettingsConfiguration : IAsyncConfigureOptions { private readonly IFacebookService _facebookService; private readonly ShellSettings _shellSettings; @@ -24,11 +24,9 @@ public FacebookSettingsConfiguration( _logger = logger; } - public void Configure(FacebookSettings options) + public async ValueTask ConfigureAsync(FacebookSettings options) { - var settings = GetFacebookSettingsAsync() - .GetAwaiter() - .GetResult(); + var settings = await GetFacebookSettingsAsync(); if (settings != null) { diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Settings/FacebookSettings.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Settings/FacebookSettings.cs index 41edf857317..f8fbb93ef08 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Settings/FacebookSettings.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Settings/FacebookSettings.cs @@ -1,6 +1,8 @@ +using Microsoft.Extensions.Options; + namespace OrchardCore.Facebook.Settings { - public class FacebookSettings + public class FacebookSettings : IAsyncOptions { public string AppId { get; set; } public string AppSecret { get; set; } diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Startup.cs index c3b60367320..db6cc1b367f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Startup.cs @@ -36,7 +36,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddRecipeExecutionStep(); services.AddTransient, ResourceManagementOptionsConfiguration>(); - services.AddTransient, FacebookSettingsConfiguration>(); + services.Configure(); services.Configure((options) => { diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GitHubAuthenticationSettingsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GitHubAuthenticationSettingsConfiguration.cs index 75843108f94..3f93ebfbbf8 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GitHubAuthenticationSettingsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GitHubAuthenticationSettingsConfiguration.cs @@ -9,7 +9,7 @@ namespace OrchardCore.GitHub.Configuration; -public class GitHubAuthenticationSettingsConfiguration : IConfigureOptions +public class GitHubAuthenticationSettingsConfiguration : IAsyncConfigureOptions { private readonly IGitHubAuthenticationService _gitHubAuthenticationService; private readonly ShellSettings _shellSettings; @@ -25,11 +25,9 @@ public GitHubAuthenticationSettingsConfiguration( _logger = logger; } - public void Configure(GitHubAuthenticationSettings options) + public async ValueTask ConfigureAsync(GitHubAuthenticationSettings options) { - var settings = GetGitHubAuthenticationSettingsAsync() - .GetAwaiter() - .GetResult(); + var settings = await GetGitHubAuthenticationSettingsAsync(); if (settings != null) { diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/Settings/GithubAuthenticationSettings.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/Settings/GithubAuthenticationSettings.cs index 373f8e9e641..ea7f584000c 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/Settings/GithubAuthenticationSettings.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/Settings/GithubAuthenticationSettings.cs @@ -1,8 +1,9 @@ using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; namespace OrchardCore.GitHub.Settings { - public class GitHubAuthenticationSettings + public class GitHubAuthenticationSettings : IAsyncOptions { public string ClientID { get; set; } public string ClientSecret { get; set; } diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs index 0aeebd5ce12..e1d843d54e7 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs @@ -34,7 +34,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddRecipeExecutionStep(); - services.AddTransient, GitHubAuthenticationSettingsConfiguration>(); + services.Configure(); // Register the options initializers required by the GitHub Handler. services.TryAddEnumerable(new[] diff --git a/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleAuthenticationSettingsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleAuthenticationSettingsConfiguration.cs index 015a4ef3a1e..a1f7189e835 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleAuthenticationSettingsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleAuthenticationSettingsConfiguration.cs @@ -8,7 +8,7 @@ namespace OrchardCore.Google.Authentication.Services; -public class GoogleAuthenticationSettingsConfiguration : IConfigureOptions +public class GoogleAuthenticationSettingsConfiguration : IAsyncConfigureOptions { private readonly GoogleAuthenticationService _googleAuthenticationService; private readonly ShellSettings _shellSettings; @@ -24,11 +24,9 @@ public GoogleAuthenticationSettingsConfiguration( _logger = logger; } - public void Configure(GoogleAuthenticationSettings options) + public async ValueTask ConfigureAsync(GoogleAuthenticationSettings options) { - var settings = GetGoogleAuthenticationSettingsAsync() - .GetAwaiter() - .GetResult(); + var settings = await GetGoogleAuthenticationSettingsAsync(); if (settings != null) { diff --git a/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Settings/GoogleAuthenticationSettings.cs b/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Settings/GoogleAuthenticationSettings.cs index d761f2f6826..7a563a814af 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Settings/GoogleAuthenticationSettings.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Settings/GoogleAuthenticationSettings.cs @@ -1,8 +1,9 @@ using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; namespace OrchardCore.Google.Authentication.Settings { - public class GoogleAuthenticationSettings + public class GoogleAuthenticationSettings : IAsyncOptions { public string ClientID { get; set; } public string ClientSecret { get; set; } diff --git a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs index 38ef76841f9..289548c0667 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs @@ -44,7 +44,7 @@ public override void ConfigureServices(IServiceCollection services) ServiceDescriptor.Transient, OAuthPostConfigureOptions>() }); - services.AddTransient, GoogleAuthenticationSettingsConfiguration>(); + services.Configure(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Processing/MediaTokenOptions.cs b/src/OrchardCore.Modules/OrchardCore.Media/Processing/MediaTokenOptions.cs index 9c70b1fec53..f263dfff213 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Processing/MediaTokenOptions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Processing/MediaTokenOptions.cs @@ -1,6 +1,8 @@ +using Microsoft.Extensions.Options; + namespace OrchardCore.Media.Processing { - public class MediaTokenOptions + public class MediaTokenOptions : IAsyncOptions { public byte[] HashKey { get; set; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Processing/MediaTokenOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Media/Processing/MediaTokenOptionsConfiguration.cs index 19302b3b138..a573e216190 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Processing/MediaTokenOptionsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Processing/MediaTokenOptionsConfiguration.cs @@ -1,9 +1,10 @@ +using System.Threading.Tasks; using Microsoft.Extensions.Options; using OrchardCore.Settings; namespace OrchardCore.Media.Processing { - public class MediaTokenOptionsConfiguration : IConfigureOptions + public class MediaTokenOptionsConfiguration : IAsyncConfigureOptions { private readonly ISiteService _siteService; @@ -12,10 +13,9 @@ public MediaTokenOptionsConfiguration(ISiteService siteService) _siteService = siteService; } - public void Configure(MediaTokenOptions options) + public async ValueTask ConfigureAsync(MediaTokenOptions options) { - options.HashKey = _siteService.GetSiteSettingsAsync() - .GetAwaiter().GetResult() + options.HashKey = (await _siteService.GetSiteSettingsAsync()) .As() .HashKey; } diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs index 88ab3d9a4df..93b66ececab 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs @@ -162,7 +162,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddSingleton(); - services.AddTransient, MediaTokenOptionsConfiguration>(); + services.Configure(); services.AddScoped(sp => sp.GetRequiredService()); services.AddScoped(sp => sp.GetRequiredService()); diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADSettingsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADSettingsConfiguration.cs index 2606a5e764b..43d9221032f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADSettingsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADSettingsConfiguration.cs @@ -9,7 +9,7 @@ namespace OrchardCore.Microsoft.Authentication.Configuration; -public class AzureADSettingsConfiguration : IConfigureOptions +public class AzureADSettingsConfiguration : IAsyncConfigureOptions { private readonly IAzureADService _azureADService; private readonly ShellSettings _shellSettings; @@ -25,11 +25,9 @@ public AzureADSettingsConfiguration( _logger = logger; } - public void Configure(AzureADSettings options) + public async ValueTask ConfigureAsync(AzureADSettings options) { - var settings = GetAzureADSettingsAsync() - .GetAwaiter() - .GetResult(); + var settings = await GetAzureADSettingsAsync(); if (settings != null) { diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountSettingsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountSettingsConfiguration.cs index a92a8ec9b00..582b70a7103 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountSettingsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountSettingsConfiguration.cs @@ -9,7 +9,7 @@ namespace OrchardCore.Microsoft.Authentication.Configuration; -public class MicrosoftAccountSettingsConfiguration : IConfigureOptions +public class MicrosoftAccountSettingsConfiguration : IAsyncConfigureOptions { private readonly IMicrosoftAccountService _microsoftAccountService; private readonly ShellSettings _shellSettings; @@ -25,11 +25,9 @@ public MicrosoftAccountSettingsConfiguration( _logger = logger; } - public void Configure(MicrosoftAccountSettings options) + public async ValueTask ConfigureAsync(MicrosoftAccountSettings options) { - var settings = GetMicrosoftAccountSettingsAsync() - .GetAwaiter() - .GetResult(); + var settings = await GetMicrosoftAccountSettingsAsync(); if (settings != null) { diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs index f9cc1326d0b..8aedcfba34d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs @@ -33,7 +33,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddRecipeExecutionStep(); - services.AddTransient, MicrosoftAccountSettingsConfiguration>(); + services.Configure(); // Register the options initializers required by the Microsoft Account Handler. services.TryAddEnumerable(new[] @@ -60,7 +60,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped, AzureADSettingsDisplayDriver>(); services.AddScoped(); - services.AddTransient, AzureADSettingsConfiguration>(); + services.Configure(); // Register the options initializers required by the Policy Scheme, Cookie and OpenId Connect Handler. services.TryAddEnumerable(new[] diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Settings/AzureADSettings.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Settings/AzureADSettings.cs index cf87240f01b..dd6eb403a93 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Settings/AzureADSettings.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Settings/AzureADSettings.cs @@ -1,8 +1,9 @@ using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; namespace OrchardCore.Microsoft.Authentication.Settings { - public class AzureADSettings + public class AzureADSettings : IAsyncOptions { public string DisplayName { get; set; } public string AppId { get; set; } diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Settings/MicrosoftAccountSettings.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Settings/MicrosoftAccountSettings.cs index 3655120635b..81d6d89edfa 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Settings/MicrosoftAccountSettings.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Settings/MicrosoftAccountSettings.cs @@ -1,8 +1,9 @@ using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Options; namespace OrchardCore.Microsoft.Authentication.Settings { - public class MicrosoftAccountSettings + public class MicrosoftAccountSettings : IAsyncOptions { public string AppId { get; set; } public string AppSecret { get; set; } diff --git a/src/OrchardCore.Modules/OrchardCore.Search/Model/SearchSettings.cs b/src/OrchardCore.Modules/OrchardCore.Search/Model/SearchSettings.cs index 98cb737ebe5..58f05394629 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search/Model/SearchSettings.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search/Model/SearchSettings.cs @@ -1,6 +1,8 @@ +using Microsoft.Extensions.Options; + namespace OrchardCore.Search.Models { - public class SearchSettings + public class SearchSettings : IAsyncOptions { public string ProviderName { get; set; } diff --git a/src/OrchardCore.Modules/OrchardCore.Search/Services/SearchSettingsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Search/Services/SearchSettingsConfiguration.cs index 10ed1292d67..572aebd8ad6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search/Services/SearchSettingsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search/Services/SearchSettingsConfiguration.cs @@ -1,11 +1,11 @@ +using System.Threading.Tasks; using Microsoft.Extensions.Options; -using OrchardCore.Entities; using OrchardCore.Search.Models; using OrchardCore.Settings; namespace OrchardCore.Search.Configuration { - public class SearchSettingsConfiguration : IConfigureOptions + public class SearchSettingsConfiguration : IAsyncConfigureOptions { private readonly ISiteService _site; @@ -14,11 +14,9 @@ public SearchSettingsConfiguration(ISiteService site) _site = site; } - public void Configure(SearchSettings options) + public async ValueTask ConfigureAsync(SearchSettings options) { - var settings = _site.GetSiteSettingsAsync() - .GetAwaiter().GetResult() - .As(); + var settings = (await _site.GetSiteSettingsAsync()).As(); options.ProviderName = settings.ProviderName; } diff --git a/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs index 89151ad533f..e1de197cfc0 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs @@ -30,7 +30,7 @@ public class Startup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient, SearchSettingsConfiguration>(); + services.Configure(); services.AddScoped(); services.AddScoped(); services.AddScoped, SearchSettingsDisplayDriver>(); diff --git a/src/OrchardCore.Modules/OrchardCore.Security/Services/SecuritySettingsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Security/Services/SecuritySettingsConfiguration.cs index 7d155643fa7..025329410d4 100644 --- a/src/OrchardCore.Modules/OrchardCore.Security/Services/SecuritySettingsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Security/Services/SecuritySettingsConfiguration.cs @@ -1,19 +1,19 @@ +using System.Threading.Tasks; using Microsoft.Extensions.Options; using OrchardCore.Security.Settings; namespace OrchardCore.Security.Services { - public class SecuritySettingsConfiguration : IConfigureOptions + public class SecuritySettingsConfiguration : IAsyncConfigureOptions { private readonly ISecurityService _securityService; public SecuritySettingsConfiguration(ISecurityService securityService) => _securityService = securityService; - public void Configure(SecuritySettings options) + public async ValueTask ConfigureAsync(SecuritySettings options) { - var securitySettings = _securityService.GetSettingsAsync() - .GetAwaiter().GetResult(); + var securitySettings = await _securityService.GetSettingsAsync(); options.ContentSecurityPolicy = securitySettings.ContentSecurityPolicy; options.ContentTypeOptions = securitySettings.ContentTypeOptions; diff --git a/src/OrchardCore.Modules/OrchardCore.Security/Settings/SecuritySettings.cs b/src/OrchardCore.Modules/OrchardCore.Security/Settings/SecuritySettings.cs index 8431c216e45..6992bc83a5f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Security/Settings/SecuritySettings.cs +++ b/src/OrchardCore.Modules/OrchardCore.Security/Settings/SecuritySettings.cs @@ -1,10 +1,11 @@ using System.Collections.Generic; using System.Linq; +using Microsoft.Extensions.Options; using OrchardCore.Security.Options; namespace OrchardCore.Security.Settings { - public class SecuritySettings + public class SecuritySettings : IAsyncOptions { private Dictionary _contentSecurityPolicy = new(); private Dictionary _permissionsPolicy = new(); diff --git a/src/OrchardCore.Modules/OrchardCore.Security/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Security/Startup.cs index dcb81b83cb7..a62a1b5a1cb 100644 --- a/src/OrchardCore.Modules/OrchardCore.Security/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Security/Startup.cs @@ -24,7 +24,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddSingleton(); - services.AddTransient, SecuritySettingsConfiguration>(); + services.Configure(); } public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/Services/TwitterSettingsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Twitter/Services/TwitterSettingsConfiguration.cs index 14433f8c3d7..c1214cc642b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Twitter/Services/TwitterSettingsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/Services/TwitterSettingsConfiguration.cs @@ -8,7 +8,7 @@ namespace OrchardCore.Twitter.Services; -public class TwitterSettingsConfiguration : IConfigureOptions +public class TwitterSettingsConfiguration : IAsyncConfigureOptions { private readonly ITwitterSettingsService _twitterSettingsService; private readonly ShellSettings _shellSettings; @@ -24,11 +24,9 @@ public TwitterSettingsConfiguration( _logger = logger; } - public void Configure(TwitterSettings options) + public async ValueTask ConfigureAsync(TwitterSettings options) { - var settings = GetTwitterSettingsAsync() - .GetAwaiter() - .GetResult(); + var settings = await GetTwitterSettingsAsync(); if (settings != null) { diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/Settings/TwitterSettings.cs b/src/OrchardCore.Modules/OrchardCore.Twitter/Settings/TwitterSettings.cs index 30aee3499f6..5f8c6addf56 100644 --- a/src/OrchardCore.Modules/OrchardCore.Twitter/Settings/TwitterSettings.cs +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/Settings/TwitterSettings.cs @@ -1,6 +1,8 @@ +using Microsoft.Extensions.Options; + namespace OrchardCore.Twitter.Settings { - public class TwitterSettings + public class TwitterSettings : IAsyncOptions { public string ConsumerKey { get; set; } public string ConsumerSecret { get; set; } diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs index 0626ba49ba1..b59120062ee 100644 --- a/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs @@ -43,7 +43,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddRecipeExecutionStep(); services.AddTransient(); - services.AddTransient, TwitterSettingsConfiguration>(); + services.Configure(); services.AddHttpClient() .AddHttpMessageHandler() diff --git a/src/OrchardCore/OrchardCore.ReCaptcha.Core/Configuration/ReCaptchaSettings.cs b/src/OrchardCore/OrchardCore.ReCaptcha.Core/Configuration/ReCaptchaSettings.cs index 9ef25e413fb..dcb20911c77 100644 --- a/src/OrchardCore/OrchardCore.ReCaptcha.Core/Configuration/ReCaptchaSettings.cs +++ b/src/OrchardCore/OrchardCore.ReCaptcha.Core/Configuration/ReCaptchaSettings.cs @@ -1,6 +1,8 @@ +using Microsoft.Extensions.Options; + namespace OrchardCore.ReCaptcha.Configuration { - public class ReCaptchaSettings + public class ReCaptchaSettings : IAsyncOptions { public string SiteKey { get; set; } diff --git a/src/OrchardCore/OrchardCore.ReCaptcha.Core/Configuration/ReCaptchaSettingsConfiguration.cs b/src/OrchardCore/OrchardCore.ReCaptcha.Core/Configuration/ReCaptchaSettingsConfiguration.cs index 454791c15fe..e2bd94af725 100644 --- a/src/OrchardCore/OrchardCore.ReCaptcha.Core/Configuration/ReCaptchaSettingsConfiguration.cs +++ b/src/OrchardCore/OrchardCore.ReCaptcha.Core/Configuration/ReCaptchaSettingsConfiguration.cs @@ -1,10 +1,10 @@ +using System.Threading.Tasks; using Microsoft.Extensions.Options; -using OrchardCore.Entities; using OrchardCore.Settings; namespace OrchardCore.ReCaptcha.Configuration { - public class ReCaptchaSettingsConfiguration : IConfigureOptions + public class ReCaptchaSettingsConfiguration : IAsyncConfigureOptions { private readonly ISiteService _site; @@ -13,11 +13,9 @@ public ReCaptchaSettingsConfiguration(ISiteService site) _site = site; } - public void Configure(ReCaptchaSettings options) + public async ValueTask ConfigureAsync(ReCaptchaSettings options) { - var settings = _site.GetSiteSettingsAsync() - .GetAwaiter().GetResult() - .As(); + var settings = (await _site.GetSiteSettingsAsync()).As(); options.SiteKey = settings.SiteKey; options.SecretKey = settings.SecretKey; diff --git a/src/OrchardCore/OrchardCore.ReCaptcha.Core/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.ReCaptcha.Core/ServiceCollectionExtensions.cs index c65d2109119..8d492c7fc90 100644 --- a/src/OrchardCore/OrchardCore.ReCaptcha.Core/ServiceCollectionExtensions.cs +++ b/src/OrchardCore/OrchardCore.ReCaptcha.Core/ServiceCollectionExtensions.cs @@ -19,7 +19,7 @@ public static IServiceCollection AddReCaptcha(this IServiceCollection services, .AddTransientHttpErrorPolicy(policy => policy.WaitAndRetryAsync(3, attempt => TimeSpan.FromSeconds(0.5 * attempt))); services.AddSingleton(); - services.AddTransient, ReCaptchaSettingsConfiguration>(); + services.Configure(); services.AddTagHelpers(); diff --git a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Extensions/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Extensions/ServiceCollectionExtensions.cs index d503af12949..aabc496e2b7 100644 --- a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Extensions/ServiceCollectionExtensions.cs +++ b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Extensions/ServiceCollectionExtensions.cs @@ -28,7 +28,7 @@ public static bool TryAddAzureAISearchServices(this IServiceCollection services, logger.LogError("Azure AI Search module is enabled. However, the connection settings are not provided in configuration file."); } - services.AddTransient, AzureAISearchDefaultOptionsConfigurations>(); + services.Configure(); services.AddAzureClientsCore(); diff --git a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Models/AzureAISearchDefaultOptions.cs b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Models/AzureAISearchDefaultOptions.cs index 7af891c0c95..a98d737126a 100644 --- a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Models/AzureAISearchDefaultOptions.cs +++ b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Models/AzureAISearchDefaultOptions.cs @@ -1,9 +1,10 @@ using Azure; using Azure.Search.Documents.Indexes.Models; +using Microsoft.Extensions.Options; namespace OrchardCore.Search.AzureAI.Models; -public class AzureAISearchDefaultOptions +public class AzureAISearchDefaultOptions : IAsyncOptions { public const string DefaultAnalyzer = LexicalAnalyzerName.Values.StandardLucene; diff --git a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchDefaultOptionsConfigurations.cs b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchDefaultOptionsConfigurations.cs index 51b799e4e70..ef22b850473 100644 --- a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchDefaultOptionsConfigurations.cs +++ b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchDefaultOptionsConfigurations.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Azure; using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.Configuration; @@ -8,7 +9,7 @@ namespace OrchardCore.Search.AzureAI.Services; -public class AzureAISearchDefaultOptionsConfigurations : IConfigureOptions +public class AzureAISearchDefaultOptionsConfigurations : IAsyncConfigureOptions { public const string ProtectorName = "AzureAISearch"; @@ -26,7 +27,7 @@ public AzureAISearchDefaultOptionsConfigurations( _siteService = siteService; } - public async void Configure(AzureAISearchDefaultOptions options) + public async ValueTask ConfigureAsync(AzureAISearchDefaultOptions options) { var fileOptions = _shellConfiguration.GetSection("OrchardCore_AzureAISearch").Get() ?? new AzureAISearchDefaultOptions(); diff --git a/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaTokenTests.cs b/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaTokenTests.cs index 0409fec46d1..197d9fbc976 100644 --- a/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaTokenTests.cs +++ b/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaTokenTests.cs @@ -82,7 +82,7 @@ private IServiceProvider CreateServiceProvider() services.AddSingleton(); services.AddSingleton(); services.AddScoped(); - services.AddTransient, MediaTokenOptionsConfiguration>(); + services.Configure(); var serviceProvider = services.BuildServiceProvider();