-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44487fa
commit 546ae75
Showing
39 changed files
with
1,381 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>Samples.Gomoku.Abstractions</RootNamespace> | ||
<AssemblyName>Samples.Gomoku.Abstractions</AssemblyName> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" /> | ||
<PackageReference Include="Stl.Fusion.Client" Version="0.9.59" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Stl.Fusion; | ||
|
||
namespace Samples.Gomoku.Abstractions | ||
{ | ||
public interface ITimeService | ||
{ | ||
[ComputeMethod(KeepAliveTime = 1)] | ||
Task<DateTime> GetTimeAsync(CancellationToken cancellationToken = default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26124.0 | ||
MinimumVisualStudioVersion = 15.0.26124.0 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Abstractions", "Abstractions\Abstractions.csproj", "{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UI", "UI\UI.csproj", "{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Services", "Services\Services.csproj", "{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Host", "Host\Host.csproj", "{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Debug|x64.Build.0 = Debug|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Debug|x86.Build.0 = Debug|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Release|x64.ActiveCfg = Release|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Release|x64.Build.0 = Release|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Release|x86.ActiveCfg = Release|Any CPU | ||
{04BEC4E8-9182-4DAF-ABF1-7E80542F5C89}.Release|x86.Build.0 = Release|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Debug|x64.Build.0 = Debug|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Debug|x86.Build.0 = Debug|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Release|x64.ActiveCfg = Release|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Release|x64.Build.0 = Release|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Release|x86.ActiveCfg = Release|Any CPU | ||
{4AAE940A-184F-4179-A5F2-26CE7C5F1CC8}.Release|x86.Build.0 = Release|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Debug|x64.Build.0 = Debug|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Debug|x86.Build.0 = Debug|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Release|x64.ActiveCfg = Release|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Release|x64.Build.0 = Release|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Release|x86.ActiveCfg = Release|Any CPU | ||
{9EDD9C09-4060-4BA1-BCB7-A05FC05A6507}.Release|x86.Build.0 = Release|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Debug|x64.Build.0 = Debug|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Debug|x86.Build.0 = Debug|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Release|x64.ActiveCfg = Release|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Release|x64.Build.0 = Release|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Release|x86.ActiveCfg = Release|Any CPU | ||
{CBEAEAFD-CDCA-4FFE-B8BE-8243DA75E6FC}.Release|x86.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Stl.Fusion.Server; | ||
using Samples.Gomoku.Abstractions; | ||
|
||
namespace Samples.Gomoku.Host.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
[ApiController, JsonifyErrors] | ||
public class TimeController : ControllerBase, ITimeService | ||
{ | ||
private readonly ITimeService _time; | ||
|
||
public TimeController(ITimeService time) => _time = time; | ||
|
||
[HttpGet("get"), Publish] | ||
public Task<DateTime> GetTimeAsync(CancellationToken cancellationToken) | ||
=> _time.GetTimeAsync(cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
<RootNamespace>Samples.Gomoku.Host</RootNamespace> | ||
<AssemblyName>Samples.Gomoku.Host</AssemblyName> | ||
<ServerGarbageCollection>true</ServerGarbageCollection> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AspNet.Security.OAuth.GitHub" Version="5.0.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="5.0.2" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.2" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.2" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.2" /> | ||
<PackageReference Include="Stl.Fusion.Server" Version="0.9.59" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\UI\UI.csproj" /> | ||
<ProjectReference Include="..\Services\Services.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Update="Pages\_Host.cshtml" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" /> | ||
<None Include="$(ProjectDir)\Resources\**" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" LinkBase="Resources\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script> | ||
|
||
<script src="_content/Blazorise/blazorise.js"></script> | ||
<script src="_content/Blazorise.Bootstrap/blazorise.bootstrap.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0/css/all.css"> | ||
|
||
<link href="_content/Blazorise/blazorise.css" rel="stylesheet" /> | ||
<link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
@page "/" | ||
@namespace Samples.Gomoku.Host.Pages | ||
@using Samples.Gomoku.UI | ||
@using Stl.Async | ||
@using Stl.Fusion.Server.Authentication | ||
@using Stl.Fusion.Server.Controllers | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | ||
@inject ServerAuthHelper ServerAuthHelper | ||
@inject ServerSettings ServerSettings | ||
@{ | ||
Task.Run(() => ServerAuthHelper.UpdateAuthStateAsync(HttpContext)).Ignore(); | ||
var authSchemas = await ServerAuthHelper.GetSchemasAsync(HttpContext); | ||
var sessionId = ServerAuthHelper.Session.Id.Value; | ||
var isServerSideBlazor = BlazorModeController.IsServerSideBlazor(HttpContext); | ||
var isCloseWindowRequest = ServerAuthHelper.IsCloseWindowRequest(HttpContext, out var closeWindowFlowName); | ||
Layout = null; | ||
} | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||
<title>Fusion+Blazorise Template</title> | ||
<base href="~/" /> | ||
<link href="css/app.css" rel="stylesheet" /> | ||
|
||
<partial name="Blazorise.Head" /> | ||
<script src="_content/Stl.Fusion.Blazor/scripts/fusionAuth.js"></script> | ||
<script> | ||
window.FusionAuth.schemas = "@authSchemas"; | ||
window.FusionAuth.sessionId = "@sessionId"; | ||
</script> | ||
</head> | ||
<body> | ||
@if (isCloseWindowRequest) { | ||
<script> | ||
setTimeout(function () { | ||
window.close(); | ||
}, 500) | ||
</script> | ||
<div class="alert alert-primary"> | ||
@(closeWindowFlowName) completed, you can close this window. | ||
</div> | ||
} else if (!isServerSideBlazor) { | ||
<app id="app">Loading...</app> | ||
|
||
<div id="blazor-error-ui"> | ||
An unhandled error has occurred. | ||
<a href="" class="reload">Reload</a> | ||
<a class="dismiss">🗙</a> | ||
</div> | ||
|
||
<partial name="Blazorise.Body" /> | ||
<script type="module" src="./js/app.js"></script> | ||
<script src="_framework/blazor.webassembly.js"></script> | ||
} else { | ||
<app> | ||
@(await Html.RenderComponentAsync<App>(RenderMode.ServerPrerendered, new { SessionId = sessionId })) | ||
</app> | ||
|
||
<div id="blazor-error-ui"> | ||
<environment include="Staging,Production"> | ||
An error has occurred. This application may no longer respond until reloaded. | ||
</environment> | ||
<environment include="Development"> | ||
An unhandled exception has occurred. See browser dev tools for details. | ||
</environment> | ||
<a href="" class="reload">Reload</a> | ||
<a class="dismiss">🗙</a> | ||
</div> | ||
|
||
<partial name="Blazorise.Body" /> | ||
<script type="module" src="./js/app.js"></script> | ||
<script src="_framework/blazor.server.js"></script> | ||
} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Configuration.Memory; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Samples.Gomoku.Host; | ||
using Samples.Gomoku.Services; | ||
|
||
var host = Host.CreateDefaultBuilder() | ||
.ConfigureHostConfiguration(builder => { | ||
// Looks like there is no better way to set _default_ URL | ||
builder.Sources.Insert(0, new MemoryConfigurationSource() { | ||
InitialData = new Dictionary<string, string>() { | ||
{WebHostDefaults.ServerUrlsKey, "http://localhost:5005"}, | ||
} | ||
}); | ||
}) | ||
.ConfigureWebHostDefaults(builder => builder | ||
.UseDefaultServiceProvider((ctx, options) => { | ||
if (ctx.HostingEnvironment.IsDevelopment()) { | ||
options.ValidateScopes = true; | ||
options.ValidateOnBuild = true; | ||
} | ||
}) | ||
.UseStartup<Startup>()) | ||
.Build(); | ||
|
||
// Ensure the DB is created | ||
var dbContextFactory = host.Services.GetRequiredService<IDbContextFactory<AppDbContext>>(); | ||
await using var dbContext = dbContextFactory.CreateDbContext(); | ||
await dbContext.Database.EnsureDeletedAsync(); | ||
await dbContext.Database.EnsureCreatedAsync(); | ||
|
||
await host.RunAsync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Text; | ||
using Stl.DependencyInjection; | ||
|
||
namespace Samples.Gomoku.Host | ||
{ | ||
[Settings("Server")] | ||
public class ServerSettings | ||
{ | ||
public bool UseInMemoryAuthService { get; set; } = false; | ||
public string PublisherId { get; set; } = "p"; | ||
|
||
public string MicrosoftAccountClientId { get; set; } = "6839dbf7-d1d3-4eb2-a7e1-ce8d48f34d00"; | ||
public string MicrosoftAccountClientSecret { get; set; } = | ||
Encoding.UTF8.GetString(Convert.FromBase64String( | ||
"REFYeH4yNTNfcVNWX2h0WkVoc1V6NHIueDN+LWRxUTA2Zw==")); | ||
|
||
public string GitHubClientId { get; set; } = "7a38bc415f7e1200fee2"; | ||
public string GitHubClientSecret { get; set; } = | ||
Encoding.UTF8.GetString(Convert.FromBase64String( | ||
"OGNkMTAzM2JmZjljOTk3ODc5MjhjNTNmMmE3Y2Q1NWU0ZmNlNjU0OA==")); | ||
} | ||
} |
Oops, something went wrong.