Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Added support for generic host based IWebHostBuilder #1580

Merged
merged 19 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions samples/GenericWebHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Net;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Hosting;

namespace GenericWebHost
{
Expand All @@ -19,22 +18,20 @@ public static async Task Main(string[] args)
config.AddJsonFile("appsettings.json", optional: true);
config.AddCommandLine(args);
})
.ConfigureServices((hostContext, services) =>
{
})
.UseFakeServer()
.ConfigureWebHost((hostContext, app) =>
.ConfigureWebHost(builder =>
{
app.Run(async (context) =>
builder.Configure(app =>
{
await context.Response.WriteAsync("Hello World!");
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
});
})
.UseConsoleLifetime()
.Build();

var s = host.Services;

await host.RunAsync();
}
}
Expand Down
43 changes: 0 additions & 43 deletions samples/GenericWebHost/WebHostExtensions.cs

This file was deleted.

62 changes: 0 additions & 62 deletions samples/GenericWebHost/WebHostService.cs

This file was deleted.

11 changes: 0 additions & 11 deletions samples/GenericWebHost/WebHostServiceOptions.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading;

namespace Microsoft.AspNetCore.Hosting.Internal
{
internal class GenericWebHostApplicationLifetime : IApplicationLifetime
{
private readonly Microsoft.Extensions.Hosting.IApplicationLifetime _applicationLifetime;
public GenericWebHostApplicationLifetime(Microsoft.Extensions.Hosting.IApplicationLifetime applicationLifetime)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You from a year ago is trolling you now 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

{
_applicationLifetime = applicationLifetime;
}

public CancellationToken ApplicationStarted => _applicationLifetime.ApplicationStarted;

public CancellationToken ApplicationStopping => _applicationLifetime.ApplicationStopping;

public CancellationToken ApplicationStopped => _applicationLifetime.ApplicationStopped;

public void StopApplication() => _applicationLifetime.StopApplication();
}
}
Loading