Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco committed Nov 6, 2024
1 parent 91c9c78 commit 74dfc40
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public override void ConfigureServices(IServiceCollection services)

services.AddDataMigration<Migrations>();
services.AddScoped<IContentTypePartDefinitionDisplayDriver, PreviewPartSettingsDisplayDriver>();
services.TryAddEnumerable(ServiceDescriptor.Singleton<IStartupFilter, PreviewStartupFilter>());
services.AddSingleton<IStartupFilter, PreviewStartupFilter>();
}
}
3 changes: 1 addition & 2 deletions src/OrchardCore.Modules/OrchardCore.Cors/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public override void ConfigureServices(IServiceCollection services)
services.AddPermissionProvider<Permissions>();
services.AddSingleton<CorsService>();

services.TryAddEnumerable(ServiceDescriptor
.Transient<IConfigureOptions<CorsOptions>, CorsOptionsConfiguration>());
services.AddTransient<IConfigureOptions<CorsOptions>, CorsOptionsConfiguration>();
}
}
2 changes: 1 addition & 1 deletion src/OrchardCore.Modules/OrchardCore.Diagnostics/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed class Startup : Modules.StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.TryAddEnumerable(ServiceDescriptor.Singleton<IStartupFilter, DiagnosticsStartupFilter>());
services.AddSingleton<IStartupFilter, DiagnosticsStartupFilter>();
}

public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
Expand Down
15 changes: 5 additions & 10 deletions src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,12 @@ public override void ConfigureServices(IServiceCollection services)
services.AddRecipeExecutionStep<FacebookLoginSettingsStep>();

// Register the options initializers required by the Facebook handler.
services.TryAddEnumerable(new[]
{
// Orchard-specific initializers:
ServiceDescriptor.Transient<IConfigureOptions<AuthenticationOptions>, FacebookLoginConfiguration>(),
ServiceDescriptor.Transient<IConfigureOptions<FacebookOptions>, FacebookLoginConfiguration>(),
// Orchard-specific initializers:
services.AddTransient<IConfigureOptions<AuthenticationOptions>, FacebookLoginConfiguration>();
services.AddTransient<IConfigureOptions<FacebookOptions>, FacebookLoginConfiguration>();

// Deployment

// Built-in initializers:
ServiceDescriptor.Transient<IPostConfigureOptions<FacebookOptions>, OAuthPostConfigureOptions<FacebookOptions, FacebookHandler>>()
});
// Built-in initializers:
services.AddTransient<IPostConfigureOptions<FacebookOptions>, OAuthPostConfigureOptions<FacebookOptions, FacebookHandler>>();
}
}

Expand Down
13 changes: 5 additions & 8 deletions src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,10 @@ public override void ConfigureServices(IServiceCollection services)
services.AddTransient<IConfigureOptions<GitHubAuthenticationSettings>, GitHubAuthenticationSettingsConfiguration>();

// Register the options initializers required by the GitHub Handler.
services.TryAddEnumerable(new[]
{
// Orchard-specific initializers:
ServiceDescriptor.Transient<IConfigureOptions<AuthenticationOptions>, GitHubOptionsConfiguration>(),
ServiceDescriptor.Transient<IConfigureOptions<GitHubOptions>, GitHubOptionsConfiguration>(),
// Built-in initializers:
ServiceDescriptor.Transient<IPostConfigureOptions<GitHubOptions>, OAuthPostConfigureOptions<GitHubOptions, GitHubHandler>>()
});
// Orchard-specific initializers:
services.AddTransient<IConfigureOptions<AuthenticationOptions>, GitHubOptionsConfiguration>();
services.AddTransient<IConfigureOptions<GitHubOptions>, GitHubOptionsConfiguration>();
// Built-in initializers:
services.AddTransient<IPostConfigureOptions<GitHubOptions>, OAuthPostConfigureOptions<GitHubOptions, GitHubHandler>>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ public override void ConfigureServices(IServiceCollection services)
services.AddNavigationProvider<GoogleAuthenticationAdminMenu>();

// Register the options initializers required by the Google Handler.
services.TryAddEnumerable(new[]
{
// Orchard-specific initializers:
ServiceDescriptor.Transient<IConfigureOptions<AuthenticationOptions>, GoogleOptionsConfiguration>(),
ServiceDescriptor.Transient<IConfigureOptions<GoogleOptions>, GoogleOptionsConfiguration>(),
// Built-in initializers:
ServiceDescriptor.Transient<IPostConfigureOptions<GoogleOptions>, OAuthPostConfigureOptions<GoogleOptions, GoogleHandler>>()
});
// Orchard-specific initializers:
services.AddTransient<IConfigureOptions<AuthenticationOptions>, GoogleOptionsConfiguration>();
services.AddTransient<IConfigureOptions<GoogleOptions>, GoogleOptionsConfiguration>();

// Built-in initializers:
services.AddTransient<IPostConfigureOptions<GoogleOptions>, OAuthPostConfigureOptions<GoogleOptions, GoogleHandler>>();

services.AddTransient<IConfigureOptions<GoogleAuthenticationSettings>, GoogleAuthenticationSettingsConfiguration>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public sealed class MicrosoftAccountStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.TryAddEnumerable(new ServiceDescriptor(typeof(IPermissionProvider), typeof(Permissions), ServiceLifetime.Scoped));
services.AddPermissionProvider<Permissions>();

services.AddSingleton<IMicrosoftAccountService, MicrosoftAccountService>();
services.AddSiteDisplayDriver<MicrosoftAccountSettingsDisplayDriver>();
Expand Down
3 changes: 1 addition & 2 deletions src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public override void ConfigureServices(IServiceCollection services)

services.AddSingleton<ReverseProxyService>();

services.TryAddEnumerable(ServiceDescriptor
.Transient<IConfigureOptions<ForwardedHeadersOptions>, ForwardedHeadersOptionsConfiguration>());
services.AddTransient<IConfigureOptions<ForwardedHeadersOptions>, ForwardedHeadersOptionsConfiguration>();
}
}

Expand Down
14 changes: 6 additions & 8 deletions src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@ public override void ConfigureServices(IServiceCollection services)
services.AddNavigationProvider<AdminMenuSignin>();
services.AddSingleton<ITwitterSigninService, TwitterSigninService>();
services.AddSiteDisplayDriver<TwitterSigninSettingsDisplayDriver>();

// Register the options initializers required by the Twitter Handler.
services.TryAddEnumerable(new[]
{
// Orchard-specific initializers:
ServiceDescriptor.Transient<IConfigureOptions<AuthenticationOptions>, TwitterOptionsConfiguration>(),
ServiceDescriptor.Transient<IConfigureOptions<TwitterOptions>, TwitterOptionsConfiguration>(),
// Built-in initializers:
ServiceDescriptor.Transient<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>()
});
// Orchard-specific initializers:
services.AddTransient<IConfigureOptions<AuthenticationOptions>, TwitterOptionsConfiguration>();
services.AddTransient<IConfigureOptions<TwitterOptions>, TwitterOptionsConfiguration>();
// Built-in initializers:
services.AddTransient<IPostConfigureOptions<TwitterOptions>, TwitterPostConfigureOptions>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public static IServiceCollection AddContentManagementDisplay(this IServiceCollec
});

services.TryAddTransient<IContentItemDisplayManager, ContentItemDisplayManager>();
services.TryAddEnumerable(new ServiceDescriptor(typeof(IContentDisplayHandler), typeof(ContentItemDisplayCoordinator), ServiceLifetime.Scoped));

services.AddScoped<IContentDisplayHandler, ContentItemDisplayCoordinator>();

services.AddScoped<IPlacementNodeFilterProvider, ContentTypePlacementNodeFilterProvider>();
services.AddScoped<IPlacementNodeFilterProvider, ContentPartPlacementNodeFilterProvider>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,9 @@ public static OrchardCoreBuilder AddLiquidViews(this OrchardCoreBuilder builder)
services.AddTransient<IConfigureOptions<TemplateOptions>, TemplateOptionsFileProviderSetup>();
services.TryAddEnumerable(
ServiceDescriptor.Transient<IConfigureOptions<LiquidViewOptions>,
LiquidViewOptionsSetup>());
services.AddTransient<IConfigureOptions<LiquidViewOptions>, LiquidViewOptionsSetup>();
services.TryAddEnumerable(
ServiceDescriptor.Transient<IConfigureOptions<ShapeTemplateOptions>,
LiquidShapeTemplateOptionsSetup>());
services.AddTransient<IConfigureOptions<ShapeTemplateOptions>, LiquidShapeTemplateOptionsSetup>();
services.AddSingleton<IApplicationFeatureProvider<ViewsFeature>, LiquidViewsFeatureProvider>();
services.AddScoped<IRazorViewExtensionProvider, LiquidViewExtensionProvider>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ public static OrchardCoreBuilder AddTheming(this OrchardCoreBuilder builder)
services.AddScoped<IShapePlacementProvider, ShapeTablePlacementProvider>();
services.TryAddEnumerable(
ServiceDescriptor.Transient<IConfigureOptions<ShapeTemplateOptions>, ShapeTemplateOptionsSetup>());
services.AddTransient<IConfigureOptions<ShapeTemplateOptions>, ShapeTemplateOptionsSetup>();
services.TryAddSingleton<IShapeTemplateFileProviderAccessor, ShapeTemplateFileProviderAccessor>();
services.AddShapeAttributes<CoreShapes>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public static OrchardCoreBuilder AddDocumentManagement(this OrchardCoreBuilder b
services.AddSingleton(typeof(IDocumentManager<>), typeof(DocumentManager<>));
services.AddSingleton(typeof(IVolatileDocumentManager<>), typeof(VolatileDocumentManager<>));
services.AddSingleton(typeof(IDocumentManager<,>), typeof(DocumentManager<,>));
services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<DocumentOptions>, DocumentOptionsSetup>());
services.AddSingleton<IConfigureOptions<DocumentOptions>, DocumentOptionsSetup>();
services.AddSingleton(typeof(IDocumentEntityManager<>), typeof(DocumentEntityManager<>));
services.AddSingleton(typeof(IVolatileDocumentEntityManager<>), typeof(VolatileDocumentEntityManager<>));
services.AddSingleton(typeof(IDocumentEntityManager<,>), typeof(DocumentEntityManager<,>));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public static class ServiceCollectionExtensions
public static IServiceCollection AddIdGeneration(this IServiceCollection services)
{
services.TryAddSingleton<IIdGenerator, DefaultIdGenerator>();
services.TryAddEnumerable(ServiceDescriptor.Singleton<IGlobalMethodProvider, IdGeneratorMethod>());
services.TryAddSingleton<IGlobalMethodProvider, IdGeneratorMethod>();

return services;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ public static IMvcCoreBuilder AddModularRazorPages(this IMvcCoreBuilder builder)

internal static IServiceCollection AddModularRazorPages(this IServiceCollection services)
{
services.TryAddEnumerable(ServiceDescriptor.Singleton<MatcherPolicy, PageEndpointComparerPolicy>());
services.AddSingleton<MatcherPolicy, PageEndpointComparerPolicy>();

services.TryAddEnumerable(
ServiceDescriptor.Transient<IConfigureOptions<RazorPagesOptions>, ModularPageRazorPagesOptionsSetup>());
services.AddTransient<IConfigureOptions<RazorPagesOptions>, ModularPageRazorPagesOptionsSetup>();

services.TryAddEnumerable(
ServiceDescriptor.Singleton<IPageApplicationModelProvider, ModularPageApplicationModelProvider>());
services.AddSingleton<IPageApplicationModelProvider, ModularPageApplicationModelProvider>();

return services;
}
Expand Down
9 changes: 3 additions & 6 deletions src/OrchardCore/OrchardCore.Mvc.Core/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public override void ConfigureServices(IServiceCollection services)
builder.AddViewLocalization();
builder.AddDataAnnotationsLocalization();

services.TryAddEnumerable(
ServiceDescriptor.Transient<IConfigureOptions<RazorViewEngineOptions>, ModularRazorViewEngineOptionsSetup>());
services.AddTransient<IConfigureOptions<RazorViewEngineOptions>, ModularRazorViewEngineOptionsSetup>();

if (_hostingEnvironment.IsDevelopment())
{
Expand All @@ -114,8 +113,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddSingleton<IViewCompilerProvider, SharedViewCompilerProvider>();
}

services.TryAddEnumerable(
ServiceDescriptor.Transient<IConfigureOptions<MvcRazorRuntimeCompilationOptions>, RazorCompilationOptionsSetup>());
services.AddTransient<IConfigureOptions<MvcRazorRuntimeCompilationOptions>, RazorCompilationOptionsSetup>();

services.AddSingleton<RazorCompilationFileProviderAccessor>();

Expand All @@ -141,7 +139,6 @@ internal static void AddMvcModuleCoreServices(IServiceCollection services)
services.AddScoped<IViewLocationExpanderProvider, ComponentViewLocationExpanderProvider>();
services.AddScoped<IViewLocationExpanderProvider, SharedViewLocationExpanderProvider>();

services.TryAddEnumerable(
ServiceDescriptor.Singleton<IApplicationModelProvider, ModularApplicationModelProvider>());
services.AddSingleton<IApplicationModelProvider, ModularApplicationModelProvider>();
}
}

0 comments on commit 74dfc40

Please sign in to comment.