mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 01:11:52 +08:00
31 lines
720 B
C#
31 lines
720 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public class ClassBuilderRuleDictionary<T, TK> : ClassBuilderRule<T>
|
|
{
|
|
public IDictionary<TK, string> Dictionary { get; set; }
|
|
|
|
public Func<T, TK> Func { get; set; }
|
|
|
|
public ClassBuilderRuleDictionary(Func<T, TK> func, IDictionary<TK, string> dictionary)
|
|
{
|
|
Func = func;
|
|
Dictionary = dictionary;
|
|
}
|
|
|
|
public override string GetClass(T data)
|
|
{
|
|
var key = Func(data);
|
|
|
|
string value;
|
|
if (Dictionary.TryGetValue(key, out value))
|
|
{
|
|
return value;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |