using System; using System.Collections.Generic; namespace AntDesign { public class ClassBuilderRuleDictionary : ClassBuilderRule { public IDictionary Dictionary { get; set; } public Func Func { get; set; } public ClassBuilderRuleDictionary(Func func, IDictionary 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; } } }