forked from nanoframework/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebServerDi.cs
More file actions
26 lines (22 loc) · 886 Bytes
/
Copy pathWebServerDi.cs
File metadata and controls
26 lines (22 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
// Copyright (c) 2020 Laurent Ellerbach and the project contributors
// See LICENSE file in the project root for full license information.
//
using System;
using System.Net;
using nanoFramework.DependencyInjection;
namespace nanoFramework.WebServer.Sample
{
internal class WebServerDi : WebServer
{
private readonly IServiceProvider _serviceProvider;
public WebServerDi(int port, HttpProtocol protocol, Type[] controllers, IServiceProvider serviceProvider) : base(port, protocol, controllers)
{
_serviceProvider = serviceProvider;
}
protected override void InvokeRoute(CallbackRoutes route, HttpListenerContext context)
{
route.Callback.Invoke(ActivatorUtilities.CreateInstance(_serviceProvider, route.Callback.DeclaringType), new object[] { new WebServerEventArgs(context) });
}
}
}