示例#1
0
 public static IExtendPipeline ReplaceRequestContext <TContext>(this IExtendPipeline bootstrapper)
     where TContext : class, IRequestContext, new()
 {
     return(bootstrapper.Extend((services, _) =>
     {
         services.ReplaceFirst <IRequestContext, TContext>(ServiceLifetime.Transient);
     }));
 }
示例#2
0
        public static IExtendPipeline ConfigureMappings(this IExtendPipeline bootstrapper,
                                                        Action <IMapperConfigurationExpression> mappingsConfiguration)
        {
            bootstrapper.Extend((services, _) =>
            {
                services.AddSingleton <ITypeMapper>(c =>
                {
                    var componentResolver = c.GetService <IComponentResolver>();
                    return(new DefaultTypeMapper(mappingsConfiguration, componentResolver));
                });
            });

            return(bootstrapper);
        }
示例#3
0
        public static IExtendPipeline ReplaceRequestContext <TContext>(this IExtendPipeline bootstrapper,
                                                                       Func <IServiceProvider, TContext> requestContextProvider) where TContext : class, IRequestContext
        {
            if (requestContextProvider == null)
            {
                throw new ArgumentNullException(nameof(requestContextProvider));
            }

            return(bootstrapper.Extend((services, _) =>
            {
                services.RemoveFirstOrNothing <IRequestContext>();
                services.AddTransient <IRequestContext>(requestContextProvider);
            }));
        }
示例#4
0
        AddServices(this IExtendPipeline bootstrapper,
                    Action <IServiceCollection, IConfiguration> serviceConfigurationProvider)
        {
            if (bootstrapper == null)
            {
                throw new ArgumentNullException(nameof(bootstrapper));
            }
            if (serviceConfigurationProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceConfigurationProvider));
            }

            var factory = new ServiceCollectionContainerFactory(serviceConfigurationProvider);

            return(bootstrapper.UseContainer(factory));
        }