-
-
Notifications
You must be signed in to change notification settings - Fork 735
/
Copy pathWebHostBuilderExtensions.cs
40 lines (37 loc) · 1.33 KB
/
WebHostBuilderExtensions.cs
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Microsoft.AspNetCore.Hosting;
using System;
namespace ElectronNET.API
{
/// <summary>
///
/// </summary>
public static class WebHostBuilderExtensions
{
/// <summary>
/// Use a Electron support for this .NET Core Project.
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="args">The arguments.</param>
/// <returns></returns>
public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[] args)
{
foreach (string argument in args)
{
if (argument.ToUpper().Contains("ELECTRONPORT"))
{
BridgeSettings.SocketPort = argument.ToUpper().Replace("/ELECTRONPORT=", "");
Console.WriteLine("Use Electron Port: " + BridgeSettings.SocketPort);
} else if(argument.ToUpper().Contains("ELECTRONWEBPORT"))
{
BridgeSettings.WebPort = argument.ToUpper().Replace("/ELECTRONWEBPORT=", "");
}
}
if(HybridSupport.IsElectronActive)
{
builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory)
.UseUrls("http://127.0.0.1:" + BridgeSettings.WebPort);
}
return builder;
}
}
}