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[Theme]()
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, ReadOnlySpan
1 value, Boolean ignoreCase, Boolean throwOnFailure, Int32& result) at System.Enum.TryParseByValueOrName[Int32](RuntimeType enumType, ReadOnlySpan
1 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[Theme]()