Пример #1
0
 public static void RegisterAssemblyByConvention(this IocBuilder iocBuilder, Assembly assembly)
 {
     foreach (var type in assembly.DefinedTypes)
     {
         RegisterTypeByConvention(iocBuilder, type);
     }
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
        public static IocBuilder New(IServiceCollection services, IStartupService startupService)
        {
            IocBuilder builder = new IocBuilder(services, startupService);

            return(builder);
        }