Exemplo n.º 1
0
        private List <GlobalFilter> FindGlobalFilters(StructureMap.IContext c)
        {
            var gbType  = typeof(GlobalFilter);
            var filters = gbType.Assembly.GetTypes().Where(x => gbType.IsAssignableFrom(x) && gbType != x)
                          .Select(Activator.CreateInstance)
                          .Select(x => x as GlobalFilter)
                          .ToList();

            filters.ForEach(c.BuildUp);
            return(filters);
        }
Exemplo n.º 2
0
        internal static List <T> FindListOfByContainer <T>(StructureMap.IContext c) where T : class
        {
            var baseType      = typeof(T);
            var appAssemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies().Where(x => x.Name.StartsWith("Varina")).Select(Assembly.Load).ToList();
            var allFoundType  = new List <T>();

            foreach (var ass in appAssemblies)
            {
                var foundTypes = ass.GetTypes().Where(x => baseType.IsAssignableFrom(x) && baseType != x && !x.IsAbstract).ToList();
                var objs       = foundTypes.Select(c.GetInstance)
                                 .Select(x => x as T)
                                 .ToList();
                allFoundType.AddRange(objs);
            }
            return(allFoundType);
        }