ant-design-blazor/components/select/EnumSelect.cs
王俊 5b3e89a07a feat(module: select): add EnumSelect for select componet with enum (#1759)
* feat(module: select): add EnumSelect for select componet with enum

* refactor: extract EnumLabelValue to the core directory

* feat: add enum select demo

* refactor: extracts the GetLabelValueList method to EnumHelper

* refactor: refactor EnumSelect with simple data source

* feat: add enum DisplayName support

* fix: modify the reflection of the enum get attribute with field

* add test

Co-authored-by: wangjun <wangjun@chemical.ai>
Co-authored-by: James Yeung <shunjiey@hotmail.com>
2021-07-26 05:16:19 +00:00

23 lines
613 B
C#

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace AntDesign
{
public class EnumSelect<TEnum> : Select<TEnum, TEnum>
{
public EnumSelect()
{
if (typeof(TEnum).IsEnum)
{
DataSource = EnumHelper<TEnum>.GetValueList();
}
}
protected override string GetLabel(TEnum item)
{
return EnumHelper<TEnum>.GetDisplayName(item);
}
}
}