jbogard / MediatR

Simple, unambitious mediator implementation in .NET
Apache License 2.0
11k stars 1.16k forks source link

BlazorStrap.CurrentTheme<Theme>() throws error (bootstrap not found because enum is Bootstrap #872

Closed Miatrix closed 1 year ago

Miatrix commented 1 year ago

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[Theme]()

jbogard commented 1 year ago

This is the wrong repo for this issue.