Exemple #1
0
        protected override Assembly[] FindAllItems()
        {
            Type baseType = typeof(IEntityRegister);

            //获取所有继承IEntityRegister 且非抽象类 的程序集
            Assembly[] assemblies = _assemblyFinder.FindAll().Where(a => a.GetTypes().Any(c => baseType.IsAssignableFrom(c) && !c.IsAbstract)).ToArray();
            return(assemblies);
        }
        protected override Type[] FindAllItems()
        {
            Type[] baseType = new Type[] { typeof(Entity <>), typeof(Entity) };
            //Type type = typeof(UserA);
            Type        type2 = typeof(Entity <>);
            var         types = _assemblyFinder.FindAll();
            List <Type> ts2   = new List <Type>();

            foreach (var item in types)
            {
                var ts = item.GetTypes();
                foreach (var t in ts)
                {
                    if (t.IsSubclassOf(type2))
                    {
                        ts2.Add(t);
                    }
                }
            }
            //var types2 = types.Where(c => baseType.Any(bt => c.IsAssignableFrom(bt))).ToArray();
            return(ts2.ToArray());
        }