public FormHelper(Type formModelType, Dictionary<T4DataType, string> fieldTypeTemplates, string defaultHtmlTemplate, string tag) { this.FormModelType = formModelType; this.FieldTypeTemplates = fieldTypeTemplates; this.DefaultHtmlTemplate = defaultHtmlTemplate; this.Tag = tag; //组特性 var t4FormGroupAttribute = formModelType.GetAttribute<T4FormGroupAttribute>(false); if (t4FormGroupAttribute != null) this.IsEnableFormGroup = true; this.T4PropertyInfos = formModelType.GetT4PropertyInfos(); if (this.IsEnableFormGroup) { this.DefaultGroupName = t4FormGroupAttribute.GroupName; this.Groups = this.T4PropertyInfos.Where(p => p.T4GroupInfo != null).Select(p => p.T4GroupInfo.Name).Distinct().ToList(); if (!this.Groups.Contains(t4FormGroupAttribute.GroupName)) this.Groups.Add(t4FormGroupAttribute.GroupName); } }
public static string T4Html(Type type, Dictionary<T4DataType, string> dic, string defaultHtmlTemplate, string tag) { if (type == null || dic == null) return string.Empty; var str = new StringBuilder(); var proInfos = type.GetT4PropertyInfos(); //组特性 var t4FormGroupAttribute = type.GetAttribute<T4FormGroupAttribute>(false); var groups = new List<string>(); foreach (var item in proInfos) { } //foreach (PropertyInfo pro in type.GetProperties()) //{ // var html = pro.T4Html(dic, defaultHtmlTemplate, tag); // if (!string.IsNullOrEmpty(html)) // str.AppendLine(html); //} return str.ToString(); }