Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
CAPCHIK committed Dec 31, 2019
1 parent 445f80f commit abf7d16
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Excursion360.Desktop.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29521.150
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Excursion360.Desktop", "Excursion360.Desktop\Excursion360.Desktop.csproj", "{57AB85E0-518E-4278-846B-50B2A63B6C4C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{57AB85E0-518E-4278-846B-50B2A63B6C4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{57AB85E0-518E-4278-846B-50B2A63B6C4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57AB85E0-518E-4278-846B-50B2A63B6C4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57AB85E0-518E-4278-846B-50B2A63B6C4C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A23D4AEF-7BC6-4281-B5BA-CE087ABAD54C}
EndGlobalSection
EndGlobal
17 changes: 17 additions & 0 deletions Excursion360.Desktop/Excursion360.Desktop.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions Excursion360.Desktop/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace Excursion360.Desktop
{
static class Extensions
{
public static ILogger CreateLogger(this IWebHost host, string categoryName)
{
return host.Services.GetService<ILoggerFactory>().CreateLogger(categoryName);
}
}
}
69 changes: 69 additions & 0 deletions Excursion360.Desktop/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.Extensions.Configuration;
using Microsoft.AspNetCore.Hosting.Server.Features;
using System.Linq;
using System.Threading.Tasks;

namespace Excursion360.Desktop
{
class Program
{
static async Task Main(string[] args)
{
var host = WebHost
.CreateDefaultBuilder()
.UseWebRoot("")
.Configure(app => app.UseStaticFiles())
.ConfigureLogging(logs =>
{
logs.SetMinimumLevel(LogLevel.Information);
})
.Build();

var firefoxInstallLogger = host.CreateLogger("FireFox.Installer");

if (!IsFirefoxInstalled(firefoxInstallLogger))
{
if (!TryInstallFirefox(firefoxInstallLogger))
{
return;
}
}
var hostTask = host.RunAsync().ConfigureAwait(false);

var url = host.ServerFeatures
.Get<IServerAddressesFeature>()
.Addresses
.Single(a => a.StartsWith("http:", StringComparison.Ordinal));

StartFirefox(host.CreateLogger("FireFox.Start"), url);

await hostTask;
}


static bool IsFirefoxInstalled(ILogger logger)
{
logger.LogInformation("Checking for firefox...");
// TODO
return true;
}

static bool TryInstallFirefox(ILogger logger)
{
logger.LogInformation("Installing firefox...");
// TODO
return true;
}

private static void StartFirefox(ILogger logger, string url)
{
logger.LogInformation($"Starting firefox on {url}");
}
}
}

0 comments on commit abf7d16

Please # to comment.