mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 18:46:43 +00:00
Basis for configuration
This commit is contained in:
parent
b034fa24bc
commit
719b66fdb0
4 changed files with 43 additions and 0 deletions
10
Capy64/Assets/default.json
Normal file
10
Capy64/Assets/default.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
|
||||
"HTTP": {
|
||||
"Blacklist": [],
|
||||
"WebSockets": {
|
||||
"Enable": true,
|
||||
"MaxActiveConnections": 5
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,6 +12,12 @@
|
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\default.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\default.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\font.ttf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
14
Capy64/Configuration/WebSockets.cs
Normal file
14
Capy64/Configuration/WebSockets.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Configuration;
|
||||
|
||||
class WebSockets
|
||||
{
|
||||
public bool Enable { get; set; } = true;
|
||||
public int MaxActiveConnections { get; set; } = 5;
|
||||
}
|
|
@ -1,10 +1,23 @@
|
|||
using Capy64;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using var game = new Capy64.Capy64();
|
||||
using IHost host = Host.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration((context, c) =>
|
||||
{
|
||||
var settingsPath = Path.Combine(Capy64.Capy64.AppDataPath, "settings.json");
|
||||
if (!File.Exists(settingsPath))
|
||||
{
|
||||
File.Copy("Assets/default.json", settingsPath);
|
||||
}
|
||||
|
||||
c.AddJsonFile("Assets/default.json", false);
|
||||
c.AddJsonFile(settingsPath, false);
|
||||
})
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
services.AddSingleton<IGame>(game);
|
||||
|
|
Loading…
Reference in a new issue