Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ardalis/SmartEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
ardalis committed Nov 19, 2024
2 parents c500b88 + fe57f0c commit b0d3d9a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/SmartEnum/SmartEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public abstract class SmartEnum<TEnum, TValue> :
where TEnum : SmartEnum<TEnum, TValue>
where TValue : IEquatable<TValue>, IComparable<TValue>
{
static readonly Lazy<TEnum[]> _enumOptions =
new Lazy<TEnum[]>(GetAllOptions, LazyThreadSafetyMode.ExecutionAndPublication);
static readonly Lazy<List<TEnum>> _enumOptions =
new Lazy<List<TEnum>>(GetAllOptions, LazyThreadSafetyMode.ExecutionAndPublication);

static readonly Lazy<Dictionary<string, TEnum>> _fromName =
new Lazy<Dictionary<string, TEnum>>(() => _enumOptions.Value.ToDictionary(item => item.Name));
Expand All @@ -67,15 +67,15 @@ public abstract class SmartEnum<TEnum, TValue> :
return dictionary;
});

private static TEnum[] GetAllOptions()
private static List<TEnum> GetAllOptions()
{
Type baseType = typeof(TEnum);
return Assembly.GetAssembly(baseType)
.GetTypes()
.Where(t => baseType.IsAssignableFrom(t))
.SelectMany(t => t.GetFieldsOfType<TEnum>())
.OrderBy(t => t.Name)
.ToArray();
.ToList();
}

private static IEqualityComparer<TValue> GetValueComparer()
Expand Down

0 comments on commit b0d3d9a

Please sign in to comment.