예제 #1
0
        public static IServiceCollection AddMessageServiceAction(this IServiceCollection services, Action <GreetingOptions> optionsAction)
        {
            var options = new GreetingOptions();

            optionsAction(options);
            return(services.AddScoped <IMessageService>(factory => new MessageService(options)));
        }
예제 #2
0
 public MessageService(GreetingOptions options)
 {
     _options = options;
 }
예제 #3
0
 public static IApplicationBuilder UseGreetingMiddleware(this IApplicationBuilder app, GreetingOptions options)
 {
     return(app.UseMiddleware <GreetingMiddleware>(options));
 }
예제 #4
0
 public static IServiceCollection AddMessageService(this IServiceCollection services, GreetingOptions options)
 {
     return(services.AddScoped <IMessageService>(factory => new MessageService(options)));
 }
예제 #5
0
 public GreetingMiddleware(RequestDelegate next, GreetingOptions options)
 {
     _next    = next;
     _options = options;
 }