Skip to content
Open
Changes from all commits
Commits
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
41 changes: 34 additions & 7 deletions Rnwood.Smtp4dev/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,20 @@ public class Program

private static ILogger _log;

public const string Reset = "\u001b[0m";
public const string Bold = "\u001b[1m";
public const string White = "\u001b[37m";
public const string Blue = "\u001b[34m";
public const string Yellow = "\u001b[33m";

public static async Task Main(string[] args)
{
try
{




var host = await StartApp(args, false, null);

if (host == null)
Expand Down Expand Up @@ -82,6 +92,22 @@ public static async Task<IHost> StartApp(IEnumerable<string> args, bool isDeskto
_log = Log.ForContext<Program>();

string version = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;


string[] envelope = [
$"{Blue}┌────────────.{Reset}",
$"{Blue}|\\ / \\{Reset} {Yellow}version {version}",
$"{Blue}| \\ / \\{Reset} {Yellow}https://github.com/rnwood/smtp4dev",
$"{Blue}| {Bold}{White}smtp4dev{Reset}{Blue} /{Reset} {Yellow}{System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription}",
$"{Blue}| /{Reset}",
$"{Blue}└────────────'{Reset}",
$"{Reset}" ];
foreach (var line in envelope)
{
Console.Error.WriteLine(line);
}


_log.Information("smtp4dev version {version}", version);
_log.Information("https://github.com/rnwood/smtp4dev");
_log.Information(".NET Core runtime version: {netcoreruntime}", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription);
Expand Down Expand Up @@ -175,7 +201,7 @@ private static IHost BuildWebHost(string[] args, CommandLineOptions cmdLineOptio
var env = hostingContext.HostingEnvironment;

configBuilder.Sources.Clear();
foreach(var source in cb.Sources)
foreach (var source in cb.Sources)
{
configBuilder.Sources.Add(source);
}
Expand All @@ -187,7 +213,7 @@ private static IHost BuildWebHost(string[] args, CommandLineOptions cmdLineOptio
{
CmdLineArgs = Environment.GetCommandLineArgs(),
CmdLineOptions = cmdLineOptions,
Sources = cb.Sources.Select( s=>
Sources = cb.Sources.Select(s =>
{
var source = new ConfigurationBuilder().Add(s).Build();

Expand Down Expand Up @@ -217,7 +243,7 @@ private static IHost BuildWebHost(string[] args, CommandLineOptions cmdLineOptio
c.UseStartup<Startup>();
c.UseShutdownTimeout(TimeSpan.FromSeconds(10));


ServerOptions serverOptions = config.GetSection("ServerOptions").Get<ServerOptions>();

if (!string.IsNullOrEmpty(cmdLineOptions.Urls))
Expand All @@ -240,7 +266,7 @@ private static IHost BuildWebHost(string[] args, CommandLineOptions cmdLineOptio
});

builder.UseWindowsService(s => s.ServiceName = "smtp4dev");




Expand Down Expand Up @@ -322,11 +348,12 @@ internal class SettingsResultDebugInfo
public RelayOptions RelayOption { get; set; }
public DesktopOptions DesktopOptions { get; set; }
}


[JsonSourceGenerationOptions(WriteIndented = true)]

[JsonSourceGenerationOptions(WriteIndented = true)]
[JsonSerializable(typeof(SettingsDebugInfo))]
internal partial class SettingsDebugInfoSerializationContext : JsonSerializerContext {
internal partial class SettingsDebugInfoSerializationContext : JsonSerializerContext
{

}
}
Loading