using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace T4 { /// /// T4实体模型信息类 /// public class T4ModelInfo { public string ModelName { get; set; } public string Name { get; set; } public string Description { get; set; } public IEnumerable Properties { get; set; } public T4ModelInfo(Type modelType) { var nameSpace = modelType.Namespace; if (nameSpace==null) { return; } var index = nameSpace.LastIndexOf('.') + 1; ModelName = nameSpace.Substring(index, nameSpace.Length - index); Name = modelType.Name; var descAttributes = modelType.GetCustomAttributes(typeof(DescriptionAttribute), true); Description = descAttributes.Length == 1 ? ((DescriptionAttribute) descAttributes[0]).Description : Name; Properties = modelType.GetProperties(); } } }