public string Generate(object obj, IEnumerable <DynamicModel.RuntimeModelMeta.ModelPropertyMeta> properties) { StringBuilder builder = new StringBuilder(); foreach (var item in properties) { //根据showtype获取表单构造器 IDynamicFormFieldGenerator fieldGenerator = _fieldGeneratorProvider.Get(item.ShowType); builder.Append(fieldGenerator.Generate(obj, item)); } return(builder.ToString()); }
public IDynamicFormFieldGenerator Get(string type) { if (_generators == null) { _generators = GetDynamicFormFieldGenerators(); } if (_generators == null) { throw new NotSupportedException("IDynamicFormFieldGenerator"); } //根据type找到第一个符合条件的构造器,并返回 IDynamicFormFieldGenerator g = _generators.FirstOrDefault(m => m.ForType == type); if (g == null) { throw new NotSupportedException("not supproted for " + type + "'s form field generator"); } return(g); }