Skip to content

Commit

Permalink
Upgrade to use generic IHostBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Jul 13, 2020
1 parent dc7682f commit 1e60840
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
22 changes: 12 additions & 10 deletions MyApp.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System;
using System;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ServiceStack;

namespace MyApp.Api
Expand All @@ -14,12 +14,14 @@ public static void Main(string[] args)
{
Console.Title = "API";

BuildWebHost(args).Run();
CreateHostBuilder(args).Build().Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(builder =>
{
builder.UseModularStartup<Startup>();
});
}
}
}
23 changes: 13 additions & 10 deletions MyApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using System;
using System;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using ServiceStack;

namespace MyApp
{
Expand All @@ -13,12 +14,14 @@ public static void Main(string[] args)
{
Console.Title = "MVC Client";

BuildWebHost(args).Run();
CreateHostBuilder(args).Build().Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(builder =>
{
builder.UseModularStartup<Startup>();
});
}
}
}

0 comments on commit 1e60840

Please sign in to comment.