依赖注入 批量注册

 public static Dictionary<Type, Type[]> NewGetImpleAndInterfaces(string assemblyName, string suffix)
        {
            if (!String.IsNullOrEmpty(assemblyName))
            {
                var result = new Dictionary<Type, Type[]>();
                foreach (var item in Assembly.Load(assemblyName)
                    .GetTypes()
                    .Where(x => !x.IsInterface && x.Name.Contains(suffix) && !x.IsGenericType)
                    .ToList())
                {
                    result.Add(item, item.GetInterfaces());
                }
                return result;
            }
            return new Dictionary<Type, Type[]>();
        }

posted @ 2019-05-13 09:27  淩牧  阅读(246)  评论(0编辑  收藏  举报