using System; using System.Collections.Generic; using System.Linq; namespace AntDesign { public class ClassBuilder { public ClassBuilder If(string className, Func func) { _rules.Add(new ClassBuilderRuleIf(className, func)); return this; } public ClassBuilder Get(Func func) { _rules.Add(new ClassBuilderRuleGet(func)); return this; } public ClassBuilder Class(string className) { _rules.Add(new ClassBuilderRuleClass(className)); return this; } public ClassBuilder Dictionary(Func func, IDictionary dictionary) { _rules.Add(new ClassBuilderRuleDictionary(func, dictionary)); return this; } private readonly List> _rules = new List>(); public string GetClasses(T data) { return string.Join(" ", _rules.Select(i => i.GetClass(data)).Where(i => i != null)); } } }