Client configuration +di

This commit is contained in:
danielgrabowski 2019-10-31 13:08:42 +01:00
parent 7348833ab8
commit ce7ff300f4
9 changed files with 87 additions and 14 deletions

View File

@ -1,12 +1,24 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Squirrowse.Client namespace Squirrowse.Client
{ {
class Program public class Program
{ {
static void Main(string[] args) public static void Main(string[] args)
{ {
Console.WriteLine("Hello World!"); CreateHostBuilder(args).Build().Run();
} }
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
});
} }
} }

View File

@ -0,0 +1,10 @@
{
"profiles": {
"Squirrowse.Client": {
"commandName": "Project",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -1,15 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<UserSecretsId>dotnet-Squirrowse.Client-D6805387-040A-46DF-9DAE-926B46C981A6</UserSecretsId>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="3.0.0-*" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.0.0" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.0.0" />
<PackageReference Include="System.Reactive.Linq" Version="4.0.0" />
<PackageReference Include="OpenCvSharp4.Windows" Version="4.1.1.20191021" /> <PackageReference Include="OpenCvSharp4.Windows" Version="4.1.1.20191021" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Squirrowse.Client
{
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
public Worker(ILogger<Worker> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
await Task.Delay(1000, stoppingToken);
}
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -9,6 +9,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MediatR" Version="7.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="3.0.0-*" /> <PackageReference Include="Microsoft.AspNetCore.App" Version="3.0.0-*" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.0.0" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="3.0.0" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.0" /> <PackageReference Include="NLog.Web.AspNetCore" Version="4.9.0" />

View File

@ -1,3 +1,5 @@
using System.Reflection;
using MediatR;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@ -20,6 +22,7 @@ namespace Squirrowse.Service
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddControllers(); services.AddControllers();
services.AddMediatR(Assembly.GetAssembly(typeof(Startup)));
services.AddSignalR() services.AddSignalR()
.AddHubOptions<StreamHub>(opt => opt.MaximumReceiveMessageSize = 102400000)//~100mb per frame instead of 32kb default .AddHubOptions<StreamHub>(opt => opt.MaximumReceiveMessageSize = 102400000)//~100mb per frame instead of 32kb default
.AddMessagePackProtocol(); .AddMessagePackProtocol();

View File

@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.29411.108
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squirrowse.Service", "Squirrowse.Service\Squirrowse.Service.csproj", "{8C085621-BAAA-4E96-B027-561BC18751EE}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squirrowse.Service", "Squirrowse.Service\Squirrowse.Service.csproj", "{8C085621-BAAA-4E96-B027-561BC18751EE}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squirrowse.Client", "Squirrowse.Client\Squirrowse.Client.csproj", "{A523B8A9-958B-45EC-B5E4-54FDF08C1C5D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squirrowse.Client", "Squirrowse.Client\Squirrowse.Client.csproj", "{558A5917-6AD3-4C40-ACA1-EE3B8B8927C8}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -17,10 +17,10 @@ Global
{8C085621-BAAA-4E96-B027-561BC18751EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {8C085621-BAAA-4E96-B027-561BC18751EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C085621-BAAA-4E96-B027-561BC18751EE}.Release|Any CPU.ActiveCfg = Release|Any CPU {8C085621-BAAA-4E96-B027-561BC18751EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C085621-BAAA-4E96-B027-561BC18751EE}.Release|Any CPU.Build.0 = Release|Any CPU {8C085621-BAAA-4E96-B027-561BC18751EE}.Release|Any CPU.Build.0 = Release|Any CPU
{A523B8A9-958B-45EC-B5E4-54FDF08C1C5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {558A5917-6AD3-4C40-ACA1-EE3B8B8927C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A523B8A9-958B-45EC-B5E4-54FDF08C1C5D}.Debug|Any CPU.Build.0 = Debug|Any CPU {558A5917-6AD3-4C40-ACA1-EE3B8B8927C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A523B8A9-958B-45EC-B5E4-54FDF08C1C5D}.Release|Any CPU.ActiveCfg = Release|Any CPU {558A5917-6AD3-4C40-ACA1-EE3B8B8927C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A523B8A9-958B-45EC-B5E4-54FDF08C1C5D}.Release|Any CPU.Build.0 = Release|Any CPU {558A5917-6AD3-4C40-ACA1-EE3B8B8927C8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE