Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extension method for easier ResourceManagementOptions registration (Lombiq Technologies: OCORE-208) #17095

Merged
merged 9 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.ContentFields/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Fluid;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.ContentFields.Drivers;
using OrchardCore.ContentFields.Fields;
using OrchardCore.ContentFields.Handlers;
Expand All @@ -16,7 +15,6 @@
using OrchardCore.Data.Migration;
using OrchardCore.Indexing;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;
using OrchardCore.Users;

namespace OrchardCore.ContentFields;
Expand All @@ -25,7 +23,7 @@ public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();

services.Configure<TemplateOptions>(o =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentPreview.Drivers;
Expand All @@ -9,15 +8,14 @@
using OrchardCore.ContentPreview.Settings;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.ResourceManagement;

namespace OrchardCore.ContentPreview;

public sealed class Startup : Modules.StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();

services.AddScoped<IContentDisplayDriver, ContentPreviewDriver>();

Expand Down
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.ContentTypes/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.ContentManagement;
using OrchardCore.ContentTypes.Deployment;
using OrchardCore.ContentTypes.Editors;
Expand All @@ -10,7 +9,6 @@
using OrchardCore.Navigation;
using OrchardCore.Recipes;
using OrchardCore.Recipes.Events;
using OrchardCore.ResourceManagement;
using OrchardCore.Security.Permissions;

namespace OrchardCore.ContentTypes;
Expand All @@ -37,7 +35,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddRecipeExecutionStep<DeleteContentDefinitionStep>();

services.AddTransient<IRecipeEventHandler, LuceneRecipeEventHandler>();
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/OrchardCore.Modules/OrchardCore.Facebook/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.Recipes;
using OrchardCore.ResourceManagement;
using OrchardCore.Security.Permissions;

namespace OrchardCore.Facebook;
Expand All @@ -33,7 +32,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddSiteDisplayDriver<FacebookSettingsDisplayDriver>();
services.AddRecipeExecutionStep<FacebookSettingsStep>();

services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();
services.AddTransient<IConfigureOptions<FacebookSettings>, FacebookSettingsConfiguration>();

services.Configure<MvcOptions>((options) =>
Expand Down
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.Flows/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Fluid;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentTypes.Editors;
Expand All @@ -13,7 +12,6 @@
using OrchardCore.Flows.ViewModels;
using OrchardCore.Indexing;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;

namespace OrchardCore.Flows;

Expand Down Expand Up @@ -48,6 +46,6 @@ public override void ConfigureServices(IServiceCollection services)

services.AddDataMigration<Migrations>();

services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();
}
}
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.Liquid/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.Data.Migration;
Expand All @@ -20,7 +19,6 @@
using OrchardCore.Liquid.Services;
using OrchardCore.Liquid.ViewModels;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;

namespace OrchardCore.Liquid;

Expand Down Expand Up @@ -80,7 +78,7 @@ public override void ConfigureServices(IServiceCollection services)
.AddLiquidFilter<ShapeRenderFilter>("shape_render")
.AddLiquidFilter<ShapeStringifyFilter>("shape_stringify");

services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/OrchardCore.Modules/OrchardCore.Media/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
using OrchardCore.Modules.FileProviders;
using OrchardCore.Navigation;
using OrchardCore.Recipes;
using OrchardCore.ResourceManagement;
using OrchardCore.Security.Permissions;
using OrchardCore.Shortcodes;
using SixLabors.ImageSharp.Web.Caching;
Expand Down Expand Up @@ -85,7 +84,7 @@ public override void ConfigureServices(IServiceCollection services)
.AddLiquidFilter<AssetUrlFilter>("asset_url")
.AddLiquidFilter<ResizeUrlFilter>("resize_url");

services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();

services.AddTransient<IConfigureOptions<MediaOptions>, MediaOptionsConfiguration>();

Expand Down
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.Notifications/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.Admin.Models;
using OrchardCore.Data;
using OrchardCore.Data.Migration;
Expand All @@ -17,7 +16,6 @@
using OrchardCore.Notifications.Migrations;
using OrchardCore.Notifications.Models;
using OrchardCore.Notifications.Services;
using OrchardCore.ResourceManagement;
using OrchardCore.Security.Permissions;
using OrchardCore.Users;
using OrchardCore.Users.Models;
Expand Down Expand Up @@ -66,7 +64,7 @@ public override void ConfigureServices(IServiceCollection services)

services.Configure<NotificationOptions>(_shellConfiguration.GetSection("OrchardCore_Notifications"));

services.AddTransient<IConfigureOptions<ResourceManagementOptions>, NotificationOptionsConfiguration>();
services.AddResourceConfiguration<NotificationOptionsConfiguration>();
services.AddDisplayDriver<User, UserNotificationPreferencesPartDisplayDriver>();
services.AddDisplayDriver<Navbar, NotificationNavbarDisplayDriver>();
services.AddScoped<INotificationEvents, CacheNotificationEventsHandler>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\..\OrchardCore\OrchardCore.DisplayManagement.Liquid\OrchardCore.DisplayManagement.Liquid.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Module.Targets\OrchardCore.Module.Targets.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement.Core\OrchardCore.ResourceManagement.Core.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" />
</ItemGroup>

</Project>
3 changes: 1 addition & 2 deletions src/OrchardCore.Modules/OrchardCore.Resources/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.DisplayManagement.Liquid;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Modules;
Expand Down Expand Up @@ -31,7 +30,7 @@ public override void ConfigureServices(IServiceCollection serviceCollection)
o.LiquidViewParserConfiguration.Add(parser => parser.RegisterParserBlock("styleblock", parser.ArgumentsListParser, StyleBlock.WriteToAsync));
});

serviceCollection.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
serviceCollection.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();

var resourceConfiguration = _shellConfiguration.GetSection("OrchardCore_Resources");
serviceCollection.Configure<ResourceOptions>(resourceConfiguration);
Expand Down
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.Spatial/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Fluid;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Indexing;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;
using OrchardCore.Spatial.Drivers;
using OrchardCore.Spatial.Fields;
using OrchardCore.Spatial.Handlers;
Expand All @@ -19,7 +17,7 @@ public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();

// Coordinate Field
services.AddContentField<GeoPointField>()
Expand Down
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.Templates/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.Recipes;
using OrchardCore.ResourceManagement;
using OrchardCore.Security.Permissions;
using OrchardCore.Templates.Deployment;
using OrchardCore.Templates.Recipes;
Expand All @@ -19,7 +17,7 @@ public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();

services.AddScoped<IShapeBindingResolver, TemplatesShapeBindingResolver>();
services.AddScoped<PreviewTemplatesProvider>();
Expand Down
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.Themes/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.Admin.Models;
using OrchardCore.Deployment;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.DisplayManagement.Theming;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.Recipes;
using OrchardCore.ResourceManagement;
using OrchardCore.Security.Permissions;
using OrchardCore.Themes.Deployment;
using OrchardCore.Themes.Drivers;
Expand All @@ -24,7 +22,7 @@ public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();
services.AddRecipeExecutionStep<ThemesStep>();
services.AddPermissionProvider<Permissions>();
services.AddScoped<IThemeSelector, SiteThemeSelector>();
Expand Down
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.UrlRewriting/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.Recipes;
using OrchardCore.ResourceManagement;
using OrchardCore.Security.Permissions;
using OrchardCore.UrlRewriting.Drivers;
using OrchardCore.UrlRewriting.Endpoints.Rules;
Expand All @@ -28,7 +26,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddUrlRewritingServices()
.AddNavigationProvider<AdminMenu>()
.AddPermissionProvider<UrlRewritingPermissionProvider>()
.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>()
.AddResourceConfiguration<ResourceManagementOptionsConfiguration>()
.AddDisplayDriver<RewriteRule, RewriteRulesDisplayDriver>();

// Add Apache Mod Redirect Rule.
Expand Down
3 changes: 1 addition & 2 deletions src/OrchardCore.Modules/OrchardCore.Users/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
using OrchardCore.Navigation;
using OrchardCore.Recipes;
using OrchardCore.Recipes.Services;
using OrchardCore.ResourceManagement;
using OrchardCore.Security;
using OrchardCore.Security.Permissions;
using OrchardCore.Settings.Deployment;
Expand Down Expand Up @@ -155,7 +154,7 @@ public override void ConfigureServices(IServiceCollection services)
});

services.AddTransient<IUsersAdminListFilterProvider, DefaultUsersAdminListFilterProvider>();
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, UserOptionsConfiguration>();
services.AddResourceConfiguration<UserOptionsConfiguration>();
services.AddDisplayDriver<Navbar, UserMenuNavbarDisplayDriver>();
services.AddDisplayDriver<UserMenu, UserMenuDisplayDriver>();
services.AddShapeTableProvider<UserMenuShapeTableProvider>();
Expand Down
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.Widgets/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
using OrchardCore.ContentTypes.Editors;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;
using OrchardCore.Widgets.Drivers;
using OrchardCore.Widgets.Models;
using OrchardCore.Widgets.Services;
Expand All @@ -29,6 +27,6 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<IContentTypePartDefinitionDisplayDriver, WidgetsListPartSettingsDisplayDriver>();
services.AddContentPart<WidgetMetadata>();
services.AddDataMigration<Migrations>();
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();
}
}
4 changes: 1 addition & 3 deletions src/OrchardCore.Modules/OrchardCore.Workflows/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Fluid;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.Data;
using OrchardCore.Data.Migration;
using OrchardCore.Deployment;
Expand All @@ -10,7 +9,6 @@
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.Recipes;
using OrchardCore.ResourceManagement;
using OrchardCore.Security.Permissions;
using OrchardCore.Workflows.Activities;
using OrchardCore.Workflows.Deployment;
Expand Down Expand Up @@ -85,7 +83,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddActivity<LogTask, LogTaskDisplayDriver>();

services.AddRecipeExecutionStep<WorkflowTypeStep>();
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();

services.AddTrimmingServices(_shellConfiguration);
}
Expand Down
4 changes: 1 addition & 3 deletions src/OrchardCore.Themes/TheAdmin/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.DisplayManagement.Html;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;

namespace OrchardCore.Themes.TheAdmin;

Expand All @@ -18,7 +16,7 @@ public Startup(IShellConfiguration configuration)

public override void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();
services.Configure<TheAdminThemeOptions>(_configuration.GetSection("TheAdminTheme:StyleSettings"));
}
}
4 changes: 1 addition & 3 deletions src/OrchardCore.Themes/TheAgencyTheme/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;

namespace OrchardCore.Themes.TheAgencyTheme;

public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection serviceCollection)
{
serviceCollection.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
serviceCollection.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Theme.Targets\OrchardCore.Theme.Targets.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.DisplayManagement\OrchardCore.DisplayManagement.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement.Abstractions\OrchardCore.ResourceManagement.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" />
</ItemGroup>

</Project>
Loading
Loading