From 9726a260565f29487b4da496c551c9782b4bcd5a Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 17 Apr 2014 22:25:17 -0700 Subject: [PATCH] Update based on new API changes --- samples/CookieSample/Startup.cs | 14 ++++++++------ samples/CookieSample/project.json | 1 + .../CookieAuthenticationExtensions.cs | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/samples/CookieSample/Startup.cs b/samples/CookieSample/Startup.cs index cac42ca38d..917eca2ea6 100644 --- a/samples/CookieSample/Startup.cs +++ b/samples/CookieSample/Startup.cs @@ -6,6 +6,7 @@ using Microsoft.AspNet.DependencyInjection; using Microsoft.AspNet.DependencyInjection.Fallback; using Microsoft.AspNet.Logging; using Microsoft.AspNet.Security.Cookies; +using Microsoft.AspNet.RequestContainer; namespace CookieSample { @@ -13,15 +14,16 @@ namespace CookieSample { public void Configuration(IBuilder app) { - // TODO: Move to host. - var serviceCollection = new ServiceCollection(); - serviceCollection.AddInstance(new NullLoggerFactory()); - app.ServiceProvider = serviceCollection.BuildServiceProvider(app.ServiceProvider); + app.UseServices(services => + { + // TODO: Move to host. + services.AddInstance(new NullLoggerFactory()); + }); app.UseCookieAuthentication(new CookieAuthenticationOptions() - { + { - }); + }); app.Run(async context => { diff --git a/samples/CookieSample/project.json b/samples/CookieSample/project.json index bfffda8541..656b0a6e20 100644 --- a/samples/CookieSample/project.json +++ b/samples/CookieSample/project.json @@ -6,6 +6,7 @@ "Microsoft.AspNet.Security": "", "Microsoft.AspNet.Security.Cookies": "", "Microsoft.AspNet.Hosting": "0.1-alpha-*", + "Microsoft.AspNet.RequestContainer": "0.1-alpha-*", "Microsoft.AspNet.PipelineCore": "0.1-alpha-*", "Microsoft.AspNet.Abstractions": "0.1-alpha-*", "Microsoft.AspNet.FeatureModel": "0.1-alpha-*", diff --git a/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationExtensions.cs b/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationExtensions.cs index c32f3e7b80..6c7e7e6bd7 100644 --- a/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationExtensions.cs +++ b/src/Microsoft.AspNet.Security.Cookies/CookieAuthenticationExtensions.cs @@ -22,8 +22,8 @@ namespace Microsoft.AspNet public static IBuilder UseCookieAuthentication([NotNull] this IBuilder app, [NotNull] CookieAuthenticationOptions options) { // TODO: Use UseMiddleware to inject dependencies once it can discover Invoke from a base class. - var dataProtectionProvider = app.ServiceProvider.GetService(); - var loggerFactory = app.ServiceProvider.GetService(); + var dataProtectionProvider = app.ApplicationServices.GetService(); + var loggerFactory = app.ApplicationServices.GetService(); return app.Use(next => new CookieAuthenticationMiddleware(next, dataProtectionProvider, loggerFactory, options).Invoke); } }