public static void RegisterAssemblyByConvention(this IocBuilder iocBuilder, Assembly assembly) { foreach (var type in assembly.DefinedTypes) { RegisterTypeByConvention(iocBuilder, type); } }
private static void RegisterTypeByConvention(IocBuilder iocBuilder, TypeInfo type) { if (type.IsAbstract || type.IsInterface || type.IsGenericTypeDefinition) { return; } var ignoreAttribute = type.GetCustomAttribute <IgnoreAttribute>(); if (ignoreAttribute != null) { return; } var registration = iocBuilder.RegisterType(type.AsType()); IocConventionOptions options = GlobalSettings.Instance.IocConventionOptions(); foreach (var register in options.ConventionRegisters) { register.Register(registration, type); } }
public static IocBuilder New(IServiceCollection services, IStartupService startupService) { IocBuilder builder = new IocBuilder(services, startupService); return(builder); }