Closed Miatrix closed 1 year ago
What are you trying to do here?
I allow the user to pick what theme they want to display so I use something like this:
if (!string.IsNullOrWhiteSpace(Settings.Theme) && Enum.TryParse<BlazorStrap.V5.Theme>(Settings.Theme, out var userTheme) && BlazorStrap.CurrentTheme<BlazorStrap.V5.Theme>() != userTheme) await BlazorStrap.SetBootstrapCss(Settings.Theme, "5.1.3");
This worked fine in 5.0.106 but with 5.1.100 and the V5 package it gives the error due to bootstrap being lower case and the rest of the enums are Title Case. Should just be as easy as turning on the ignoreCase flag to prevent the error
Changed in 5.1.101
Confirmed fixed in 5.1.101 thanks
Version 5.1.100
It looks like:
public T CurrentTheme() where T : Enum => (T) Enum.Parse(typeof (T), this._currentTheme);
should be changed to ignore case: public T CurrentTheme() where T : Enum => (T) Enum.Parse(typeof (T), this._currentTheme, true);
Here is how I'm calling it. @using Theme = BlazorStrap.V5.Theme .... if (Enum.TryParse(Settings.Theme, out var userTheme) && BlazorStrap.CurrentTheme() != userTheme) { .... }
Here is the error: blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Requested value 'bootstrap' was not found. System.ArgumentException: Requested value 'bootstrap' was not found. at System.Enum.TryParseByName[Int32](RuntimeType enumType, ReadOnlySpan1 value, Boolean ignoreCase, Boolean throwOnFailure, Int32& result) at System.Enum.TryParseByValueOrName[Int32](RuntimeType enumType, ReadOnlySpan1 value, Boolean ignoreCase, Boolean throwOnFailure, Int32& result) at System.Enum.TryParse(Type enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, Object& result) at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase) at System.Enum.Parse(Type enumType, String value) at BlazorStrap.Service.BlazorStrapCore.CurrentTheme