jellyfin-server/Emby.Server.Implementations/HttpServerFactory.cs

77 lines
2.3 KiB
C#
Raw Normal View History

2016-11-11 03:29:51 +00:00
using System;
using System.IO;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using Emby.Server.Implementations.HttpServer;
using Emby.Server.Implementations.Net;
2016-11-11 03:29:51 +00:00
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Text;
using ServiceStack.Text.Jsv;
using SocketHttpListener.Primitives;
namespace Emby.Server.Implementations
2016-11-11 03:29:51 +00:00
{
/// <summary>
/// Class ServerFactory
/// </summary>
public static class HttpServerFactory
{
/// <summary>
/// Creates the server.
/// </summary>
/// <returns>IHttpServer.</returns>
public static IHttpServer CreateServer(IServerApplicationHost applicationHost,
ILogManager logManager,
2017-05-24 19:12:55 +00:00
IServerConfigurationManager config,
2016-11-11 03:29:51 +00:00
INetworkManager networkmanager,
IMemoryStreamFactory streamProvider,
2017-05-24 19:12:55 +00:00
string serverName,
2016-11-11 03:29:51 +00:00
string defaultRedirectpath,
ITextEncoding textEncoding,
ISocketFactory socketFactory,
ICryptoProvider cryptoProvider,
IJsonSerializer json,
IXmlSerializer xml,
IEnvironmentInfo environment,
2017-09-03 02:42:13 +00:00
X509Certificate certificate,
2017-03-12 19:27:26 +00:00
IFileSystem fileSystem,
bool enableDualModeSockets)
2016-11-11 03:29:51 +00:00
{
var logger = logManager.GetLogger("HttpServer");
return new HttpListenerHost(applicationHost,
2017-05-24 19:12:55 +00:00
logger,
config,
serverName,
defaultRedirectpath,
networkmanager,
streamProvider,
textEncoding,
socketFactory,
cryptoProvider,
json,
2016-11-11 03:29:51 +00:00
xml,
environment,
certificate,
GetParseFn,
2017-03-12 19:27:26 +00:00
enableDualModeSockets,
fileSystem);
2016-11-11 03:29:51 +00:00
}
private static Func<string, object> GetParseFn(Type propertyType)
{
return s => JsvReader.GetParseFn(propertyType)(s);
}
}
}