Beispiel #1
0
        public static void RegisterEntities(this ModelBuilder builder)
        {
            var entityRegistrations = AssemblyResolution.GetTypes <IEntityRegistration>();

            foreach (var type in entityRegistrations)
            {
                var go = Activator.CreateInstance(type) as IEntityRegistration;

                go.RegisterEntities(builder);
            }
        }
        public void Execute(IServiceCollection serviceCollection)
        {
            var typesThatImplementIRepository = AssemblyResolution.GetTypes <IRepository>().Where(x => !x.IsInterface && !x.IsAbstract);

            foreach (var type in typesThatImplementIRepository)
            {
                var interfaceToRegister = type.GetInterfaces().Where(x => x.Name.EndsWith("Repository") && !x.Name.Equals("IRepository")).FirstOrDefault();

                if (interfaceToRegister != null)
                {
                    log.LogInformation("Registered: " + interfaceToRegister.Name + " - " + type.Name);

                    serviceCollection.Add(new ServiceDescriptor(interfaceToRegister, type, ServiceLifetime.Scoped));
                }
            }
        }
Beispiel #3
0
 private static IEnumerable <Assembly> GetModuleAssemblies()
 {
     return(AssemblyResolution.GetTypes <IModule>().Select(s => s.Assembly).Distinct());
 }