/// <summary> /// 获取类型自定义特性 /// </summary> /// <param name="asm"></param> /// <returns></returns> public static ModuleAttribute GetModuleAttribute(TypeInfo asm) { ModuleAttribute temp = new ModuleAttribute(ModuleType.None, "", "", "", 0); if (asm == null) { return(temp); } object[] list = asm.GetCustomAttributes(typeof(ModuleAttribute), false); if (list.Length > 0) { return((ModuleAttribute)list[0]); } else { return(temp); } }
/// <summary> /// 获取当前程序集下模块 /// </summary> /// <returns></returns> public virtual async Task <IList <ModuleAttribute> > GetModules() { try { IList <ModuleAttribute> list = new List <ModuleAttribute>(); await Task.Run(() => { var ModList = ModuleAssembly.DefinedTypes.Where(t => t.Name.Contains("View")).ToList(); ModList.ForEach(t => { ModuleAttribute bute = GetModuleAttribute(t); if (bute.ModuleType != ModuleType.None) { list.Add(bute); } }); });; return(list); } catch { return(null); } }