| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- 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
- {
- /// <summary>
- /// T4实体模型信息类
- /// </summary>
- public class T4ModelInfo
- {
- public string ModelName { get; set; }
- public string Name { get; set; }
- public string Description { get; set; }
- public IEnumerable<PropertyInfo> 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();
- }
-
- }
- }
|