Skip to content

Commit

Permalink
Making ResourceManagerDecorator easier to update
Browse files Browse the repository at this point in the history
  • Loading branch information
Piedone committed Feb 1, 2024
1 parent c7e6e84 commit 6d6b049
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using OrchardCore.ResourceManagement;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;

Expand Down Expand Up @@ -78,11 +79,20 @@ public RequireSettings RegisterUrl(string resourceType, string resourcePath, str

public void RenderMeta(TextWriter writer) => resourceManager.RenderMeta(writer);

// Apart from the marked sections, this does the same as the method in OC's ResourceManager. This needs to be kept
// up-to-date with Orchard upgrades.
[SuppressMessage(
"StyleCop.CSharp.ReadabilityRules",
"SA1123:Do not place regions within elements",
Justification = "Needed for easier Orchard upgrades.")]
public void RenderStylesheet(TextWriter writer)
{
#region CustomCode
var displayedTheme = themeManager.GetThemeAsync().GetAwaiter().GetResult();
#endregion

var first = true;

var displayedTheme = themeManager.GetThemeAsync().GetAwaiter().GetResult();
var styleSheets = GetRequiredResources("stylesheet").ToList();

foreach (var context in styleSheets)
Expand All @@ -92,13 +102,15 @@ public void RenderStylesheet(TextWriter writer)
continue;
}

#region CustomCode
var resourceName = context.Resource.Name;
var contextIsBootstrap = resourceName.EqualsOrdinalIgnoreCase("bootstrap");

if (contextIsBootstrap && IsCurrentTheme(displayedTheme))
{
continue;
}
#endregion

if (!first)
{
Expand Down

0 comments on commit 6d6b049

Please sign in to comment.