From 5d96cb3cc1fc8c732b21d4814063355a7cd34df4 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Thu, 11 Jan 2024 12:52:41 -0800 Subject: [PATCH 1/5] Add AddDeployment extensions --- .../OrchardCore.AdminMenu/Startup.cs | 6 ++-- .../OrchardCore.ContentTypes/Startup.cs | 17 +++------- .../AddToDeploymentPlanStartup.cs | 7 ++--- .../ExportContentToDeploymentTargetStartup.cs | 6 ++-- .../OrchardCore.Contents/Startup.cs | 10 ++---- .../OrchardCore.CustomSettings/Startup.cs | 6 ++-- .../OrchardCore.Deployment/Startup.cs | 17 +++------- .../OrchardCore.Facebook/StartupLogin.cs | 6 ++-- .../OrchardCore.Features/Startup.cs | 7 ++--- .../OrchardCore.Layers/Startup.cs | 7 ++--- .../OrchardCore.Media/Startup.cs | 12 ++----- .../MicrosoftAccountStartup.cs | 6 ++-- .../OrchardCore.OpenId/Startup.cs | 10 ++---- .../OrchardCore.Placements/Startup.cs | 7 ++--- .../OrchardCore.Queries/Startup.cs | 11 +++---- .../OrchardCore.Roles/Startup.cs | 7 ++--- .../OrchardCore.Search.AzureAI/Startup.cs | 21 +++---------- .../Startup.cs | 21 +++---------- .../OrchardCore.Search.Lucene/Startup.cs | 21 +++---------- .../OrchardCore.Search/Startup.cs | 6 ++-- .../OrchardCore.Settings/Startup.cs | 6 ++-- .../OrchardCore.Shortcodes/Startup.cs | 10 +++--- .../OrchardCore.Sitemaps/Startup.cs | 8 ++--- .../OrchardCore.Templates/Startup.cs | 12 ++----- .../OrchardCore.Tenants/Startup.cs | 9 ++---- .../OrchardCore.Themes/Startup.cs | 6 ++-- .../OrchardCore.Users/Startup.cs | 10 ++---- .../OrchardCore.Workflows/Startup.cs | 6 ++-- .../Extensions/ServiceCollectionExtensions.cs | 31 +++++++++++++++++++ src/docs/releases/1.9.0.md | 10 +++++- 30 files changed, 122 insertions(+), 197 deletions(-) create mode 100644 src/OrchardCore/OrchardCore.Deployment.Abstractions/Extensions/ServiceCollectionExtensions.cs diff --git a/src/OrchardCore.Modules/OrchardCore.AdminMenu/Startup.cs b/src/OrchardCore.Modules/OrchardCore.AdminMenu/Startup.cs index fa7db0ce51c..d5ecc78de46 100644 --- a/src/OrchardCore.Modules/OrchardCore.AdminMenu/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.AdminMenu/Startup.cs @@ -9,7 +9,7 @@ using OrchardCore.AdminMenu.Deployment; using OrchardCore.AdminMenu.Recipes; using OrchardCore.AdminMenu.Services; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; @@ -39,9 +39,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddRecipeExecutionStep(); - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AdminMenuDeploymentStepDriver>(); + services.AddDeployment(); // placeholder treeNode services.AddSingleton(new AdminNodeProviderFactory()); diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Startup.cs b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Startup.cs index 028324999b2..6c231a65fb7 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Startup.cs @@ -9,8 +9,7 @@ using OrchardCore.ContentTypes.Editors; using OrchardCore.ContentTypes.RecipeSteps; using OrchardCore.ContentTypes.Services; -using OrchardCore.Deployment; -using OrchardCore.DisplayManagement.Handlers; +using OrchardCore.Deployment.Extensions; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; using OrchardCore.Navigation; @@ -140,17 +139,9 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, ContentDefinitionDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, ReplaceContentDefinitionDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, DeleteContentDefinitionDeploymentStepDriver>(); + services.AddDeployment(); + services.AddDeployment(); + services.AddDeployment(); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/AddToDeploymentPlan/AddToDeploymentPlanStartup.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/AddToDeploymentPlan/AddToDeploymentPlanStartup.cs index b8bb2aa85ac..4367d03dc83 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/AddToDeploymentPlan/AddToDeploymentPlanStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/AddToDeploymentPlan/AddToDeploymentPlanStartup.cs @@ -6,7 +6,7 @@ using OrchardCore.Admin; using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.Contents.ViewModels; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; @@ -25,9 +25,8 @@ public AddToDeploymentPlanStartup(IOptions adminOptions) public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, ContentItemDeploymentStepDriver>(); + services.AddDeployment(); + services.AddScoped(); services.AddScoped, AddToDeploymentPlanContentsAdminListDisplayDriver>(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs index f165863e270..b66081f717a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs @@ -2,7 +2,7 @@ using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.Contents.ViewModels; using OrchardCore.Data.Migration; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Navigation; @@ -20,9 +20,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped, ExportContentToDeploymentTargetSettingsDisplayDriver>(); - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, ExportContentToDeploymentTargetDeploymentStepDriver>(); + services.AddDeployment(); services.AddDataMigration(); services.AddScoped(); diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs index 5238bdb1e49..318602e60a7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs @@ -34,7 +34,7 @@ using OrchardCore.Contents.ViewModels; using OrchardCore.ContentTypes.Editors; using OrchardCore.Data.Migration; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Liquid; @@ -317,13 +317,9 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllContentDeploymentStepDriver>(); + services.AddDeployment(); - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, ContentDeploymentStepDriver>(); + services.AddDeployment(); services.AddSiteSettingsPropertyDeploymentStep(S => S["Content Audit Trail settings"], S => S["Exports the content audit trail settings."]); } diff --git a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs index 720195e9813..eae41e4f8d5 100644 --- a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs @@ -4,7 +4,7 @@ using OrchardCore.CustomSettings.Drivers; using OrchardCore.CustomSettings.Recipes; using OrchardCore.CustomSettings.Services; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Navigation; @@ -35,9 +35,7 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, CustomSettingsDeploymentStepDriver>(); + services.AddDeployment(); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/Startup.cs index 54f8baafa09..f4369c20548 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Startup.cs @@ -9,10 +9,10 @@ using OrchardCore.Deployment.Controllers; using OrchardCore.Deployment.Core; using OrchardCore.Deployment.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.Deployment.Indexes; using OrchardCore.Deployment.Recipes; using OrchardCore.Deployment.Steps; -using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; using OrchardCore.Navigation; @@ -40,13 +40,10 @@ public override void ConfigureServices(IServiceCollection services) services.AddSingleton(); // Custom File deployment step - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, CustomFileDeploymentStepDriver>(); + services.AddDeployment(); // Recipe File deployment step - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, RecipeFileDeploymentStepDriver>(); + services.AddDeploymentWithoutSource(); services.AddIndexProvider(); services.AddDataMigration(); @@ -55,13 +52,9 @@ public override void ConfigureServices(IServiceCollection services) services.AddRecipeExecutionStep(); - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, DeploymentPlanDeploymentStepDriver>(); + services.AddDeployment(); - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, JsonRecipeDeploymentStepDriver>(); + services.AddDeployment(); } public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs index 41df5b30c59..49373e4b574 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Facebook.Deployment; using OrchardCore.Facebook.Login.Configuration; @@ -48,9 +48,7 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddScoped, FacebookLoginDeploymentStepDriver>(); - services.AddTransient(); - services.AddSingleton>(); + services.AddDeployment(); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Features/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Features/Startup.cs index 083f3f683be..47146cb5f1a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Features/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Features/Startup.cs @@ -4,8 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using OrchardCore.Admin; -using OrchardCore.Deployment; -using OrchardCore.DisplayManagement.Handlers; +using OrchardCore.Deployment.Extensions; using OrchardCore.Environment.Shell.Configuration; using OrchardCore.Features.Controllers; using OrchardCore.Features.Deployment; @@ -40,9 +39,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllFeaturesDeploymentStepDriver>(); + services.AddDeployment(); } public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs index f6a03486bc5..ba9e53b234c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs @@ -11,7 +11,7 @@ using OrchardCore.ContentManagement.Handlers; using OrchardCore.Data; using OrchardCore.Data.Migration; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Layers.Controllers; using OrchardCore.Layers.Deployment; @@ -63,10 +63,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddDataMigration(); services.AddScoped(); services.AddRecipeExecutionStep(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllLayersDeploymentStepDriver>(); + services.AddDeployment(); services.AddSingleton(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs index 371b73a2542..4e703279f9c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs @@ -17,8 +17,7 @@ using OrchardCore.ContentManagement.Handlers; using OrchardCore.ContentTypes.Editors; using OrchardCore.Data.Migration; -using OrchardCore.Deployment; -using OrchardCore.DisplayManagement.Handlers; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Liquid.Tags; using OrchardCore.Environment.Shell; using OrchardCore.FileStorage; @@ -389,13 +388,8 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, MediaDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllMediaProfilesDeploymentStepDriver>(); + services.AddDeployment(); + services.AddDeployment(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs index 10ba110671e..91fd64985ea 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Identity.Web; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Microsoft.Authentication.Configuration; using OrchardCore.Microsoft.Authentication.Deployment; @@ -82,9 +82,7 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddScoped, AzureADDeploymentStepDriver>(); - services.AddTransient(); - services.AddSingleton>(); + services.AddDeployment(); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs index 582f8cb0faf..5d23a81f8a7 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs @@ -18,7 +18,7 @@ using OpenIddict.Validation.DataProtection; using OrchardCore.Admin; using OrchardCore.BackgroundTasks; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Environment.Shell.Builders; using OrchardCore.Modules; @@ -277,9 +277,7 @@ public class ServerDeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddScoped, OpenIdServerDeploymentStepDriver>(); - services.AddTransient(); - services.AddSingleton>(); + services.AddDeployment(); } } @@ -339,9 +337,7 @@ public class ValidationDeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddScoped, OpenIdValidationDeploymentStepDriver>(); - services.AddTransient(); - services.AddSingleton>(); + services.AddDeployment(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Placements/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Placements/Startup.cs index f4d24def9eb..ef3a9314206 100644 --- a/src/OrchardCore.Modules/OrchardCore.Placements/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Placements/Startup.cs @@ -6,9 +6,8 @@ using Microsoft.Extensions.Options; using OrchardCore.Admin; using OrchardCore.ContentTypes.Editors; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Descriptors; -using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; using OrchardCore.Navigation; @@ -98,9 +97,7 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, PlacementsDeploymentStepDriver>(); + services.AddDeployment(); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Queries/Startup.cs index 3f255c847ef..ffad2c8c926 100644 --- a/src/OrchardCore.Modules/OrchardCore.Queries/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Queries/Startup.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using OrchardCore.Admin; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Liquid; using OrchardCore.Modules; @@ -45,9 +45,8 @@ public override void ConfigureServices(IServiceCollection services) services.AddRecipeExecutionStep(); services.AddScoped(); - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllQueriesDeploymentStepDriver>(); + services.AddDeployment(); + services.AddSingleton(); services.Configure(o => @@ -110,9 +109,7 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, QueryBasedContentDeploymentStepDriver>(); + services.AddDeployment(); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Startup.cs index 5e3f33507c0..ddb8f5ff886 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Startup.cs @@ -7,8 +7,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.Admin; -using OrchardCore.Deployment; -using OrchardCore.DisplayManagement.Handlers; +using OrchardCore.Deployment.Extensions; using OrchardCore.Environment.Shell; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; @@ -81,9 +80,7 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllRolesDeploymentStepDriver>(); + services.AddDeployment(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs index c5239451c84..f55c8a6a089 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.Options; using OrchardCore.Admin; using OrchardCore.ContentTypes.Editors; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Environment.Shell.Configuration; using OrchardCore.Modules; @@ -112,20 +112,9 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AzureAISearchIndexDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AzureAISearchSettingsDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AzureAISearchIndexRebuildDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AzureAISearchIndexResetDeploymentStepDriver>(); + services.AddDeployment(); + services.AddDeployment(); + services.AddDeployment(); + services.AddDeployment(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs index 8a508259bd3..a7398132fbf 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs @@ -16,7 +16,7 @@ using OrchardCore.BackgroundTasks; using OrchardCore.ContentManagement; using OrchardCore.ContentTypes.Editors; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Environment.Shell.Configuration; @@ -260,21 +260,10 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, ElasticIndexDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, ElasticSettingsDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, ElasticIndexRebuildDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, ElasticIndexResetDeploymentStepDriver>(); + services.AddDeployment(); + services.AddDeployment(); + services.AddDeployment(); + services.AddDeployment(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs index 05c8758fa7a..e637f47b6de 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs @@ -11,7 +11,7 @@ using OrchardCore.ContentManagement.Handlers; using OrchardCore.ContentTypes.Editors; using OrchardCore.Data.Migration; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; @@ -130,21 +130,10 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, LuceneIndexDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, LuceneSettingsDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, LuceneIndexRebuildDeploymentStepDriver>(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, LuceneIndexResetDeploymentStepDriver>(); + services.AddDeployment(); + services.AddDeployment(); + services.AddDeployment(); + services.AddDeployment(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs index 1ab112ecf53..5fc919433e3 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs @@ -7,7 +7,7 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.Data.Migration; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; @@ -57,9 +57,7 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, SearchSettingsDeploymentStepDriver>(); + services.AddDeployment(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs index c2b6fb5644e..d90d416ca7c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using OrchardCore.Admin; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Liquid; using OrchardCore.Modules; @@ -88,9 +88,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, SiteSettingsDeploymentStepDriver>(); + services.AddDeployment(); services.AddScoped(); diff --git a/src/OrchardCore.Modules/OrchardCore.Shortcodes/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Shortcodes/Startup.cs index b3c15eb5683..6d689fe126f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Shortcodes/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Shortcodes/Startup.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using OrchardCore.Admin; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; @@ -130,19 +130,17 @@ public override void ConfigureServices(IServiceCollection services) lang, fallback "; - d.Categories = new string[] { "Localization" }; + d.Categories = ["Localization"]; }); } } [RequireFeatures("OrchardCore.Deployment", "OrchardCore.Shortcodes.Templates")] - public class ShortcodeTemplatesDeployementStartup : StartupBase + public class ShortcodeTemplatesDeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllShortcodeTemplatesDeploymentStepDriver>(); + services.AddDeployment(); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs index 09999edb4ef..b3029cab026 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs @@ -8,7 +8,7 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.Data.Migration; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; @@ -247,13 +247,11 @@ public override void ConfigureServices(IServiceCollection services) } [RequireFeatures("OrchardCore.Deployment", "OrchardCore.Sitemaps")] - public class SitemapsDeployementStartup : StartupBase + public class SitemapsDeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllSitemapsDeploymentStepDriver>(); + services.AddDeployment(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Templates/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Templates/Startup.cs index 776c706b3eb..9b81cc6547e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Templates/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Templates/Startup.cs @@ -5,9 +5,8 @@ using Microsoft.Extensions.Options; using OrchardCore.Admin; using OrchardCore.ContentTypes.Editors; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement; -using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; using OrchardCore.Navigation; @@ -47,9 +46,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllTemplatesDeploymentStepDriver>(); + services.AddDeployment(); services.AddScoped(); services.AddScoped(); @@ -105,10 +102,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddRecipeExecutionStep(); - - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllAdminTemplatesDeploymentStepDriver>(); + services.AddDeployment(); } public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) diff --git a/src/OrchardCore.Modules/OrchardCore.Tenants/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Tenants/Startup.cs index 3ff1fc049ab..f7453ea57a8 100644 --- a/src/OrchardCore.Modules/OrchardCore.Tenants/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Tenants/Startup.cs @@ -6,9 +6,8 @@ using Microsoft.Extensions.Options; using Microsoft.Net.Http.Headers; using OrchardCore.Admin; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Descriptors; -using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Environment.Shell; using OrchardCore.Environment.Shell.Configuration; using OrchardCore.Environment.Shell.Distributed; @@ -205,13 +204,11 @@ public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilde } [RequireFeatures("OrchardCore.Deployment", "OrchardCore.Tenants.FeatureProfiles")] - public class FeatureProfilesDeployementStartup : StartupBase + public class FeatureProfilesDeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllFeatureProfilesDeploymentStepDriver>(); + services.AddDeployment(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs index 44fdb42a83a..c897194a52d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Options; using OrchardCore.Admin; using OrchardCore.Admin.Models; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Theming; using OrchardCore.Modules; @@ -45,9 +45,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped(); #pragma warning restore CS0618 // Type or member is obsolete services.AddScoped(); - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, ThemesDeploymentStepDriver>(); + services.AddDeployment(); services.AddScoped, ToggleThemeNavbarDisplayDriver>(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs index 06a547db5ca..0913a53604f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs @@ -17,7 +17,7 @@ using OrchardCore.Admin.Models; using OrchardCore.Data; using OrchardCore.Data.Migration; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Theming; @@ -506,9 +506,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddScoped, CustomUserSettingsDisplayDriver>(); services.AddScoped(); - services.AddTransient(); - services.AddSingleton>(); - services.AddScoped, CustomUserSettingsDeploymentStepDriver>(); + services.AddDeployment(); } } @@ -516,9 +514,7 @@ public class UserDeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton>(); - services.AddScoped, AllUsersDeploymentStepDriver>(); + services.AddDeployment(); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Startup.cs index 970c6a36ba2..01603c8b0d9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Startup.cs @@ -7,7 +7,7 @@ using OrchardCore.Admin; using OrchardCore.Data; using OrchardCore.Data.Migration; -using OrchardCore.Deployment; +using OrchardCore.Deployment.Extensions; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Liquid; using OrchardCore.Modules; @@ -133,9 +133,7 @@ public class DeploymentStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - services.AddScoped, AllWorkflowTypeDeploymentStepDriver>(); + services.AddDeployment(); } } diff --git a/src/OrchardCore/OrchardCore.Deployment.Abstractions/Extensions/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.Deployment.Abstractions/Extensions/ServiceCollectionExtensions.cs new file mode 100644 index 00000000000..029ad2aa408 --- /dev/null +++ b/src/OrchardCore/OrchardCore.Deployment.Abstractions/Extensions/ServiceCollectionExtensions.cs @@ -0,0 +1,31 @@ +using Microsoft.Extensions.DependencyInjection; +using OrchardCore.DisplayManagement.Handlers; + +namespace OrchardCore.Deployment.Extensions; +public static class ServiceCollectionExtensions +{ + public static void AddDeployment(this IServiceCollection services) + where TSource : IDeploymentSource + where TStep : DeploymentStep, new() + { + services.AddTransient(); + services.AddSingleton(new DeploymentStepFactory()); + } + + public static void AddDeployment(this IServiceCollection services) + where TSource : IDeploymentSource + where TStep : DeploymentStep, new() + where TDisplayDriver : DisplayDriver + { + services.AddDeployment(); + services.AddScoped, TDisplayDriver>(); + } + + public static void AddDeploymentWithoutSource(this IServiceCollection services) + where TStep : DeploymentStep, new() + where TDisplayDriver : DisplayDriver + { + services.AddScoped, TDisplayDriver>(); + services.AddScoped, TDisplayDriver>(); + } +} diff --git a/src/docs/releases/1.9.0.md b/src/docs/releases/1.9.0.md index 36fe171d5a2..0a3dcf025b5 100644 --- a/src/docs/releases/1.9.0.md +++ b/src/docs/releases/1.9.0.md @@ -14,6 +14,14 @@ If you needed to enable indexing for other extensions like (`.docx`, or `.pptx`) ## Change Logs -### Azure AI Search module +### Azure AI Search Module Introducing a new "Azure AI Search" module, designed to empower you in the administration of Azure AI Search indices. When enabled with the "Search" module, it facilitates frontend full-text search capabilities through Azure AI Search. For more info read the [Azure AI Search](../reference/modules/AzureAISearch/README.md) docs. + +## Deployment Module + +Added new extensions to make registering custom deployment step easier + + - services.AddDeployment(); + - services.AddDeployment(); + - services.AddDeploymentWithoutSource(); From ff7cedf2c29ad238df1401e85d639dbba0e9c19b Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Thu, 11 Jan 2024 13:07:16 -0800 Subject: [PATCH 2/5] cleanup --- .../OrchardCore.AdminMenu/Startup.cs | 2 +- .../OrchardCore.ContentTypes/Startup.cs | 2 +- .../AddToDeploymentPlanStartup.cs | 3 +- .../ExportContentToDeploymentTargetStartup.cs | 2 +- .../OrchardCore.Contents/Startup.cs | 4 +- .../OrchardCore.CustomSettings/Startup.cs | 2 +- .../OrchardCore.Deployment/Startup.cs | 1 - .../OrchardCore.Facebook/StartupLogin.cs | 2 +- .../OrchardCore.Features/Startup.cs | 2 +- .../OrchardCore.Layers/Startup.cs | 2 +- .../OrchardCore.Media/Startup.cs | 2 +- .../MicrosoftAccountStartup.cs | 2 +- .../OrchardCore.OpenId/Startup.cs | 2 +- .../OrchardCore.Placements/Startup.cs | 2 +- .../OrchardCore.Queries/Startup.cs | 5 +-- .../OrchardCore.Roles/Startup.cs | 2 +- .../OrchardCore.Search.AzureAI/Startup.cs | 2 +- .../Startup.cs | 2 +- .../OrchardCore.Search.Lucene/Startup.cs | 2 +- .../OrchardCore.Search/Startup.cs | 2 +- .../OrchardCore.Settings/Startup.cs | 2 +- .../OrchardCore.Shortcodes/Startup.cs | 2 +- .../OrchardCore.Sitemaps/Startup.cs | 2 +- .../OrchardCore.Templates/Startup.cs | 2 +- .../OrchardCore.Tenants/Startup.cs | 2 +- .../OrchardCore.Themes/Startup.cs | 2 +- .../OrchardCore.Users/Startup.cs | 3 +- .../OrchardCore.Workflows/Startup.cs | 2 +- .../Extensions/ServiceCollectionExtensions.cs | 31 -------------- .../ServiceCollectionExtensions.cs | 42 +++++++++++++++---- 30 files changed, 60 insertions(+), 75 deletions(-) delete mode 100644 src/OrchardCore/OrchardCore.Deployment.Abstractions/Extensions/ServiceCollectionExtensions.cs diff --git a/src/OrchardCore.Modules/OrchardCore.AdminMenu/Startup.cs b/src/OrchardCore.Modules/OrchardCore.AdminMenu/Startup.cs index d5ecc78de46..dd486e5157d 100644 --- a/src/OrchardCore.Modules/OrchardCore.AdminMenu/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.AdminMenu/Startup.cs @@ -9,7 +9,7 @@ using OrchardCore.AdminMenu.Deployment; using OrchardCore.AdminMenu.Recipes; using OrchardCore.AdminMenu.Services; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Startup.cs b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Startup.cs index 6c231a65fb7..8e4fa07c4a5 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Startup.cs @@ -9,7 +9,7 @@ using OrchardCore.ContentTypes.Editors; using OrchardCore.ContentTypes.RecipeSteps; using OrchardCore.ContentTypes.Services; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; using OrchardCore.Navigation; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/AddToDeploymentPlan/AddToDeploymentPlanStartup.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/AddToDeploymentPlan/AddToDeploymentPlanStartup.cs index 4367d03dc83..b5cb3d46f5f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/AddToDeploymentPlan/AddToDeploymentPlanStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/AddToDeploymentPlan/AddToDeploymentPlanStartup.cs @@ -6,7 +6,7 @@ using OrchardCore.Admin; using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.Contents.ViewModels; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; @@ -26,7 +26,6 @@ public AddToDeploymentPlanStartup(IOptions adminOptions) public override void ConfigureServices(IServiceCollection services) { services.AddDeployment(); - services.AddScoped(); services.AddScoped, AddToDeploymentPlanContentsAdminListDisplayDriver>(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs index b66081f717a..076f02d8972 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Deployment/ExportContentToDeploymentTarget/ExportContentToDeploymentTargetStartup.cs @@ -2,7 +2,7 @@ using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.Contents.ViewModels; using OrchardCore.Data.Migration; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Navigation; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs index 318602e60a7..95e13f91951 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Startup.cs @@ -34,7 +34,7 @@ using OrchardCore.Contents.ViewModels; using OrchardCore.ContentTypes.Editors; using OrchardCore.Data.Migration; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Liquid; @@ -318,9 +318,7 @@ public class DeploymentStartup : StartupBase public override void ConfigureServices(IServiceCollection services) { services.AddDeployment(); - services.AddDeployment(); - services.AddSiteSettingsPropertyDeploymentStep(S => S["Content Audit Trail settings"], S => S["Exports the content audit trail settings."]); } } diff --git a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs index eae41e4f8d5..df5eeaf294f 100644 --- a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Startup.cs @@ -4,7 +4,7 @@ using OrchardCore.CustomSettings.Drivers; using OrchardCore.CustomSettings.Recipes; using OrchardCore.CustomSettings.Services; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Navigation; diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/Startup.cs index f4369c20548..46445fb6812 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Startup.cs @@ -9,7 +9,6 @@ using OrchardCore.Deployment.Controllers; using OrchardCore.Deployment.Core; using OrchardCore.Deployment.Deployment; -using OrchardCore.Deployment.Extensions; using OrchardCore.Deployment.Indexes; using OrchardCore.Deployment.Recipes; using OrchardCore.Deployment.Steps; diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs index 49373e4b574..9b0edfd0ed2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Facebook.Deployment; using OrchardCore.Facebook.Login.Configuration; diff --git a/src/OrchardCore.Modules/OrchardCore.Features/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Features/Startup.cs index 47146cb5f1a..b79d9e38b01 100644 --- a/src/OrchardCore.Modules/OrchardCore.Features/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Features/Startup.cs @@ -4,7 +4,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using OrchardCore.Admin; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.Environment.Shell.Configuration; using OrchardCore.Features.Controllers; using OrchardCore.Features.Deployment; diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs index ba9e53b234c..4d1460d2ab1 100644 --- a/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Layers/Startup.cs @@ -11,7 +11,7 @@ using OrchardCore.ContentManagement.Handlers; using OrchardCore.Data; using OrchardCore.Data.Migration; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Layers.Controllers; using OrchardCore.Layers.Deployment; diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs index 4e703279f9c..88ab3d9a4df 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Startup.cs @@ -17,7 +17,7 @@ using OrchardCore.ContentManagement.Handlers; using OrchardCore.ContentTypes.Editors; using OrchardCore.Data.Migration; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Liquid.Tags; using OrchardCore.Environment.Shell; using OrchardCore.FileStorage; diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs index 91fd64985ea..f9cc1326d0b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using Microsoft.Identity.Web; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Microsoft.Authentication.Configuration; using OrchardCore.Microsoft.Authentication.Deployment; diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs index 5d23a81f8a7..9154697ed55 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs @@ -18,7 +18,7 @@ using OpenIddict.Validation.DataProtection; using OrchardCore.Admin; using OrchardCore.BackgroundTasks; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Environment.Shell.Builders; using OrchardCore.Modules; diff --git a/src/OrchardCore.Modules/OrchardCore.Placements/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Placements/Startup.cs index ef3a9314206..35fd4da19aa 100644 --- a/src/OrchardCore.Modules/OrchardCore.Placements/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Placements/Startup.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Options; using OrchardCore.Admin; using OrchardCore.ContentTypes.Editors; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Queries/Startup.cs index ffad2c8c926..bb2995c8e84 100644 --- a/src/OrchardCore.Modules/OrchardCore.Queries/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Queries/Startup.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using OrchardCore.Admin; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Liquid; using OrchardCore.Modules; @@ -40,13 +40,10 @@ public override void ConfigureServices(IServiceCollection services) { services.AddScoped(); services.AddScoped(); - services.AddScoped, QueryDisplayDriver>(); services.AddRecipeExecutionStep(); services.AddScoped(); - services.AddDeployment(); - services.AddSingleton(); services.Configure(o => diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Startup.cs index ddb8f5ff886..09d03bb2a29 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Startup.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.Admin; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.Environment.Shell; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs index f55c8a6a089..b3e0f95aa8d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Startup.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.Options; using OrchardCore.Admin; using OrchardCore.ContentTypes.Editors; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Environment.Shell.Configuration; using OrchardCore.Modules; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs index a7398132fbf..d928a152f0b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Startup.cs @@ -16,7 +16,7 @@ using OrchardCore.BackgroundTasks; using OrchardCore.ContentManagement; using OrchardCore.ContentTypes.Editors; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Environment.Shell.Configuration; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs index e637f47b6de..61a50f827e7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Startup.cs @@ -11,7 +11,7 @@ using OrchardCore.ContentManagement.Handlers; using OrchardCore.ContentTypes.Editors; using OrchardCore.Data.Migration; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; diff --git a/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs index 5fc919433e3..89151ad533f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search/Startup.cs @@ -7,7 +7,7 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.Data.Migration; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; diff --git a/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs index d90d416ca7c..ec655b50be4 100644 --- a/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Settings/Startup.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using OrchardCore.Admin; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Liquid; using OrchardCore.Modules; diff --git a/src/OrchardCore.Modules/OrchardCore.Shortcodes/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Shortcodes/Startup.cs index 6d689fe126f..3d8f77cd9b2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Shortcodes/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Shortcodes/Startup.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using OrchardCore.Admin; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; diff --git a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs index b3029cab026..5fb0753847e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Startup.cs @@ -8,7 +8,7 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.Data.Migration; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; diff --git a/src/OrchardCore.Modules/OrchardCore.Templates/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Templates/Startup.cs index 9b81cc6547e..1a8d4e99a35 100644 --- a/src/OrchardCore.Modules/OrchardCore.Templates/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Templates/Startup.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Options; using OrchardCore.Admin; using OrchardCore.ContentTypes.Editors; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement; using OrchardCore.Modules; using OrchardCore.Mvc.Core.Utilities; diff --git a/src/OrchardCore.Modules/OrchardCore.Tenants/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Tenants/Startup.cs index f7453ea57a8..8af7bf11f76 100644 --- a/src/OrchardCore.Modules/OrchardCore.Tenants/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Tenants/Startup.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Options; using Microsoft.Net.Http.Headers; using OrchardCore.Admin; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.Environment.Shell; using OrchardCore.Environment.Shell.Configuration; diff --git a/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs index c897194a52d..c0ffbf920cf 100644 --- a/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Options; using OrchardCore.Admin; using OrchardCore.Admin.Models; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Theming; using OrchardCore.Modules; diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs index 0913a53604f..fe4ee8e8c45 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Startup.cs @@ -17,7 +17,7 @@ using OrchardCore.Admin.Models; using OrchardCore.Data; using OrchardCore.Data.Migration; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Theming; @@ -505,7 +505,6 @@ public override void ConfigureServices(IServiceCollection services) { services.AddScoped, CustomUserSettingsDisplayDriver>(); services.AddScoped(); - services.AddDeployment(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Startup.cs index 01603c8b0d9..373f2c73491 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Startup.cs @@ -7,7 +7,7 @@ using OrchardCore.Admin; using OrchardCore.Data; using OrchardCore.Data.Migration; -using OrchardCore.Deployment.Extensions; +using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Liquid; using OrchardCore.Modules; diff --git a/src/OrchardCore/OrchardCore.Deployment.Abstractions/Extensions/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.Deployment.Abstractions/Extensions/ServiceCollectionExtensions.cs deleted file mode 100644 index 029ad2aa408..00000000000 --- a/src/OrchardCore/OrchardCore.Deployment.Abstractions/Extensions/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using OrchardCore.DisplayManagement.Handlers; - -namespace OrchardCore.Deployment.Extensions; -public static class ServiceCollectionExtensions -{ - public static void AddDeployment(this IServiceCollection services) - where TSource : IDeploymentSource - where TStep : DeploymentStep, new() - { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); - } - - public static void AddDeployment(this IServiceCollection services) - where TSource : IDeploymentSource - where TStep : DeploymentStep, new() - where TDisplayDriver : DisplayDriver - { - services.AddDeployment(); - services.AddScoped, TDisplayDriver>(); - } - - public static void AddDeploymentWithoutSource(this IServiceCollection services) - where TStep : DeploymentStep, new() - where TDisplayDriver : DisplayDriver - { - services.AddScoped, TDisplayDriver>(); - services.AddScoped, TDisplayDriver>(); - } -} diff --git a/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs index e134adc383a..d866cabe406 100644 --- a/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs +++ b/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs @@ -1,16 +1,40 @@ using Microsoft.Extensions.DependencyInjection; +using OrchardCore.DisplayManagement.Handlers; -namespace OrchardCore.Deployment +namespace OrchardCore.Deployment; + +public static class ServiceCollectionExtensions { - public static class ServiceCollectionExtensions + public static IServiceCollection AddDeploymentTargetHandler(this IServiceCollection serviceCollection) + where TImplementation : class, IDeploymentTargetHandler + { + serviceCollection.AddScoped(); + + return serviceCollection; + } + + public static void AddDeployment(this IServiceCollection services) + where TSource : IDeploymentSource + where TStep : DeploymentStep, new() { - public static IServiceCollection AddDeploymentTargetHandler( - this IServiceCollection serviceCollection) - where TImplementation : class, IDeploymentTargetHandler - { - serviceCollection.AddScoped(); + services.AddTransient(); + services.AddSingleton(new DeploymentStepFactory()); + } - return serviceCollection; - } + public static void AddDeployment(this IServiceCollection services) + where TSource : IDeploymentSource + where TStep : DeploymentStep, new() + where TDisplayDriver : DisplayDriver + { + services.AddDeployment(); + services.AddScoped, TDisplayDriver>(); + } + + public static void AddDeploymentWithoutSource(this IServiceCollection services) + where TStep : DeploymentStep, new() + where TDisplayDriver : DisplayDriver + { + services.AddScoped, TDisplayDriver>(); + services.AddScoped, TDisplayDriver>(); } } From 16bca9e66b32353b52ed329d5224d8fe373a345f Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Thu, 11 Jan 2024 13:23:00 -0800 Subject: [PATCH 3/5] Fix registration --- .../ServiceCollectionExtensions.cs | 27 ++++++++++++++++--- .../BlogPostApiControllerTests.cs | 13 ++++++--- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs index d866cabe406..bbe203f17eb 100644 --- a/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs +++ b/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs @@ -17,8 +17,8 @@ public static void AddDeployment(this IServiceCollection service where TSource : IDeploymentSource where TStep : DeploymentStep, new() { - services.AddTransient(); - services.AddSingleton(new DeploymentStepFactory()); + services.AddDeploymentSource(); + services.AddDeploymentStep(); } public static void AddDeployment(this IServiceCollection services) @@ -27,14 +27,33 @@ public static void AddDeployment(this IServiceCo where TDisplayDriver : DisplayDriver { services.AddDeployment(); - services.AddScoped, TDisplayDriver>(); + services.AddDeploymentStepDisplayDriver(); } public static void AddDeploymentWithoutSource(this IServiceCollection services) where TStep : DeploymentStep, new() where TDisplayDriver : DisplayDriver { - services.AddScoped, TDisplayDriver>(); + services.AddDeploymentStep(); + services.AddDeploymentStepDisplayDriver(); + } + + private static void AddDeploymentSource(this IServiceCollection services) + where TSource : IDeploymentSource + { + services.AddTransient(typeof(IDeploymentSource), typeof(TSource)); + } + + private static void AddDeploymentStep(this IServiceCollection services) + where TStep : DeploymentStep, new() + { + services.AddSingleton(new DeploymentStepFactory()); + } + + private static void AddDeploymentStepDisplayDriver(this IServiceCollection services) + where TDisplayDriver : DisplayDriver + where TStep : DeploymentStep, new() + { services.AddScoped, TDisplayDriver>(); } } diff --git a/test/OrchardCore.Tests/Apis/ContentManagement/ContentApiController/BlogPostApiControllerTests.cs b/test/OrchardCore.Tests/Apis/ContentManagement/ContentApiController/BlogPostApiControllerTests.cs index e03bf8dd10a..57091b3c139 100644 --- a/test/OrchardCore.Tests/Apis/ContentManagement/ContentApiController/BlogPostApiControllerTests.cs +++ b/test/OrchardCore.Tests/Apis/ContentManagement/ContentApiController/BlogPostApiControllerTests.cs @@ -5,7 +5,6 @@ using OrchardCore.Lists.Models; using OrchardCore.Taxonomies.Fields; using OrchardCore.Tests.Apis.Context; -using YesSql; using ISession = YesSql.ISession; namespace OrchardCore.Tests.Apis.ContentManagement.ContentApiController @@ -36,9 +35,15 @@ public async Task ShouldCreateAndPublishExistingContentItem() { using var context = new BlogPostApiControllerContext(); - // Setup - await context.InitializeAsync(); - + try + { + // Setup + await context.InitializeAsync(); + } + catch (Exception ex) + { + var t = ex; + } context.BlogPost.Latest = false; context.BlogPost.Published = false; // Deliberately set these incorrectly. From 4a5db13c291947b126f78f4e22860eb356aea8eb Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Thu, 11 Jan 2024 13:23:22 -0800 Subject: [PATCH 4/5] undo changes to test --- .../BlogPostApiControllerTests.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/test/OrchardCore.Tests/Apis/ContentManagement/ContentApiController/BlogPostApiControllerTests.cs b/test/OrchardCore.Tests/Apis/ContentManagement/ContentApiController/BlogPostApiControllerTests.cs index 57091b3c139..ca0181cb5f0 100644 --- a/test/OrchardCore.Tests/Apis/ContentManagement/ContentApiController/BlogPostApiControllerTests.cs +++ b/test/OrchardCore.Tests/Apis/ContentManagement/ContentApiController/BlogPostApiControllerTests.cs @@ -35,15 +35,9 @@ public async Task ShouldCreateAndPublishExistingContentItem() { using var context = new BlogPostApiControllerContext(); - try - { - // Setup - await context.InitializeAsync(); - } - catch (Exception ex) - { - var t = ex; - } + // Setup + await context.InitializeAsync(); + context.BlogPost.Latest = false; context.BlogPost.Published = false; // Deliberately set these incorrectly. From 75477edff5bfa453c258ef23ccdbcaf534f77d4d Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Thu, 11 Jan 2024 14:37:48 -0800 Subject: [PATCH 5/5] Allow chaning --- .../ServiceCollectionExtensions.cs | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs index bbe203f17eb..3329293e4e6 100644 --- a/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs +++ b/src/OrchardCore/OrchardCore.Deployment.Abstractions/ServiceCollectionExtensions.cs @@ -5,55 +5,67 @@ namespace OrchardCore.Deployment; public static class ServiceCollectionExtensions { - public static IServiceCollection AddDeploymentTargetHandler(this IServiceCollection serviceCollection) + public static IServiceCollection AddDeploymentTargetHandler(this IServiceCollection services) where TImplementation : class, IDeploymentTargetHandler { - serviceCollection.AddScoped(); + services.AddScoped(); - return serviceCollection; + return services; } - public static void AddDeployment(this IServiceCollection services) + public static IServiceCollection AddDeployment(this IServiceCollection services) where TSource : IDeploymentSource where TStep : DeploymentStep, new() { - services.AddDeploymentSource(); - services.AddDeploymentStep(); + services.AddDeploymentSource() + .AddDeploymentStep(); + + return services; } - public static void AddDeployment(this IServiceCollection services) + public static IServiceCollection AddDeployment(this IServiceCollection services) where TSource : IDeploymentSource where TStep : DeploymentStep, new() where TDisplayDriver : DisplayDriver { - services.AddDeployment(); - services.AddDeploymentStepDisplayDriver(); + services.AddDeployment() + .AddDeploymentStepDisplayDriver(); + + return services; } - public static void AddDeploymentWithoutSource(this IServiceCollection services) + public static IServiceCollection AddDeploymentWithoutSource(this IServiceCollection services) where TStep : DeploymentStep, new() where TDisplayDriver : DisplayDriver { - services.AddDeploymentStep(); - services.AddDeploymentStepDisplayDriver(); + services.AddDeploymentStep() + .AddDeploymentStepDisplayDriver(); + + return services; } - private static void AddDeploymentSource(this IServiceCollection services) + private static IServiceCollection AddDeploymentSource(this IServiceCollection services) where TSource : IDeploymentSource { services.AddTransient(typeof(IDeploymentSource), typeof(TSource)); + + return services; } - private static void AddDeploymentStep(this IServiceCollection services) + private static IServiceCollection AddDeploymentStep(this IServiceCollection services) where TStep : DeploymentStep, new() { services.AddSingleton(new DeploymentStepFactory()); + + return services; } - private static void AddDeploymentStepDisplayDriver(this IServiceCollection services) + private static IServiceCollection AddDeploymentStepDisplayDriver(this IServiceCollection services) where TDisplayDriver : DisplayDriver where TStep : DeploymentStep, new() { services.AddScoped, TDisplayDriver>(); + + return services; } }