Beispiel #1
0
        public void RegisterAssemblyByConvention3()
        {
            var context   = new ConfigureServicesContext(null, new ServiceCollection(), null);
            var registrar = new EmptyConventionalDependencyRegistrar();

            context.AddConventionalRegistrar(registrar);
            context.Services.GetSingletonInstanceOrNull <ConventionalRegistrarList>().Contains(registrar).ShouldBeTrue();
            var assembly = typeof(ConfigureServicesContextExtensions_Tests).Assembly.GetTypes();

            context.RegisterAssemblyByConventionOfType <ConfigureServicesContextExtensions_Tests>();
            registrar.RegisterAssemblyInvoked.ShouldBeTrue();
            registrar.Types.ShouldBe(assembly);
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="context"></param>
 /// <returns></returns>
 public static ConfigureServicesContext RegisterAssemblyByConventionOfType <T>(this ConfigureServicesContext context)
 {
     context.Services.RegisterAssemblyByConventionOfType <T>();
     return(context);
 }
Beispiel #3
0
 /// <summary>
 /// 向 <see cref="IServiceCollection"/> 集合添加 <see cref="IConventionalRegistrar"/> 对象实例,用于为 <see cref="RegisterAssemblyByConvention(ConfigureServicesContext, Assembly)"/> 方法提供通用注册者。
 /// </summary>
 /// <param name="context"></param>
 /// <param name="registrar"></param>
 /// <returns></returns>
 public static ConfigureServicesContext AddConventionalRegistrar(this ConfigureServicesContext context, IConventionalRegistrar registrar)
 {
     context.Services.AddConventionalRegistrar(registrar);
     return(context);
 }
Beispiel #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 /// <param name="assembly"></param>
 /// <returns></returns>
 public static ConfigureServicesContext RegisterAssemblyByConvention(this ConfigureServicesContext context, Assembly assembly)
 {
     context.Services.RegisterAssemblyByConvention(assembly);
     return(context);
 }
Beispiel #5
0
 /// <summary>
 /// 向 <see cref="IServiceCollection"/> 集合添加 <see cref="IConventionalRegistrar"/> 对象实例,用于为 <see cref="RegisterAssemblyByConvention(ConfigureServicesContext, Assembly)"/> 方法提供通用注册者。
 /// </summary>
 /// <param name="context"></param>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public static ConfigureServicesContext AddConventionalRegistrar <T>(this ConfigureServicesContext context)
     where T : IConventionalRegistrar
 {
     context.Services.AddConventionalRegistrar <T>();
     return(context);
 }
Beispiel #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 public virtual void PostConfigureServices(ConfigureServicesContext context)
 {
 }
Beispiel #7
0
 public override void PostConfigureServices(ConfigureServicesContext context)
 {
     PostConfigureServicesCalled = true;
 }
Beispiel #8
0
 public override void ConfigureServices(ConfigureServicesContext context)
 {
     context.Services.RegisterAssemblyByConvention();
 }
Beispiel #9
0
 public override void ConfigureServices(ConfigureServicesContext context)
 {
 }