public LazyEnumerableTrees(TypeLoader typeLoader) { _lazyTrees = new Lazy <IEnumerable <ApplicationTree> >(() => { var added = new List <string>(); // Load all Controller Trees by attribute var types = typeLoader.GetTypesWithAttribute <TreeController, TreeAttribute>(); // fixme inject //convert them to ApplicationTree instances var items = types .Select(x => (tree: x, treeAttribute: x.GetCustomAttributes <TreeAttribute>(false).Single())) .Select(x => new ApplicationTree(x.treeAttribute.Initialize, x.treeAttribute.SortOrder, x.treeAttribute.ApplicationAlias, x.treeAttribute.Alias, x.treeAttribute.Title, x.treeAttribute.IconClosed, x.treeAttribute.IconOpen, x.tree.GetFullNameWithAssembly())) .ToArray(); added.AddRange(items.Select(x => x.Alias)); return(items.ToArray()); }); }
/// <summary> /// Gets all classes inheriting from BaseMapper and marked with the MapperForAttribute. /// </summary> public static IEnumerable <Type> GetAssignedMapperTypes(this TypeLoader mgr) { return(mgr.GetTypesWithAttribute <BaseMapper, MapperForAttribute>()); }
/// <summary> /// Returns all available TreeApiController's in application that are attribute with TreeAttribute /// </summary> /// <param name="mgr"></param> /// <returns></returns> internal static IEnumerable <Type> GetAttributedTreeControllers(this TypeLoader mgr) { return(mgr.GetTypesWithAttribute <TreeController, TreeAttribute>()); }