2019-12-08 00:51:07 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign
|
2019-12-08 00:51:07 +08:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|