예제 #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);
            }));
        }