diff --git a/src/MusicStore/Program.cs b/src/MusicStore/Program.cs index 5ccf11dfff..2e986e9642 100644 --- a/src/MusicStore/Program.cs +++ b/src/MusicStore/Program.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using Microsoft.AspNet.Hosting; using Microsoft.Framework.ConfigurationModel; -using Microsoft.Framework.DependencyInjection; namespace MusicStore { @@ -12,38 +11,20 @@ namespace MusicStore /// public class Program { - private readonly IServiceProvider _hostServiceProvider; - - public Program(IServiceProvider hostServiceProvider) - { - _hostServiceProvider = hostServiceProvider; - } - public Task Main(string[] args) { //Add command line configuration source to read command line parameters. var config = new Configuration(); config.AddCommandLine(args); - var serviceCollection = HostingServices.Create(_hostServiceProvider); - var services = serviceCollection.BuildServiceProvider(); - var applicationLifetime = services.GetRequiredService(); - var context = new HostingContext() { - ApplicationLifetime = applicationLifetime, Configuration = config, ServerFactoryLocation = "Microsoft.AspNet.Server.WebListener", ApplicationName = "MusicStore" }; - var engine = services.GetService(); - if (engine == null) - { - throw new Exception("TODO: IHostingEngine service not available exception"); - } - - using (engine.Start(context)) + using (new HostingEngine().Start(context)) { Console.WriteLine("Started the server.."); Console.WriteLine("Press any key to stop the server");