Merge branch 'features/nuget_autobuild' into develop

pull/8/head
Matija Koželj 2 years ago
commit 0ce199e5ee

@ -0,0 +1,2 @@
dotnet build ../src/Connected/Connected.csproj
dotnet build ../src/Connected.Client/Connected.Client.csproj

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="%PACKAGEHOME%/External" />
</config>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<disabledPackageSources />
</configuration>

@ -1,4 +1,5 @@
using Connected.Configuration;
using System.Text.Json;
using Connected.Configuration;
using Connected.Events;
using Connected.Net;
using Connected.Startup;
@ -20,6 +21,8 @@ public class ClientStartup : IStartup
if (events is null)
throw new NullReferenceException(nameof(EventConnection));
Console.WriteLine(JsonSerializer.Serialize(host.Configuration));
await events.Initialize();
await events.Connect();
@ -30,8 +33,8 @@ public class ClientStartup : IStartup
{
services.AddSingleton<EventConnection>();
services.AddSingleton(typeof(IEventService), typeof(EventService));
services.AddSingleton(typeof(IConfigurationService), typeof(ConfigurationService));
services.AddSingleton(typeof(IRemoteProviderService), typeof(RemoteProviderService));
services.AddSingleton(typeof(IConfigurationService), typeof(ConfigurationService));
await Task.CompletedTask;
}

@ -1,10 +1,12 @@
namespace Connected.Configuration;
using Microsoft.Extensions.Configuration;
namespace Connected.Configuration;
internal class ConfigurationService : IConfigurationService
{
public ConfigurationService()
public ConfigurationService(IConfiguration configuration)
{
Remote = new RemoteConfiguration();
Remote = new RemoteConfiguration(configuration.GetSection("remote"));
}
public IRemoteConfiguration Remote { get; }

@ -1,6 +1,10 @@
namespace Connected.Configuration;
using System.Collections.Immutable;
namespace Connected.Configuration;
public interface IRemoteConfiguration
{
List<string> Servers { get; }
ImmutableList<IRemoteServerConfiguration> Servers { get; }
public ImmutableList<IRemoteServerConfiguration> Query(string id);
}

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Connected.Configuration;
public interface IRemoteServerConfiguration
{
public string? Id { get; }
public string? Address { get; }
}

@ -1,13 +1,23 @@
namespace Connected.Configuration;
using System.Collections.Immutable;
using Connected.Remote;
using Microsoft.Extensions.Configuration;
namespace Connected.Configuration;
internal class RemoteConfiguration : IRemoteConfiguration
{
public RemoteConfiguration()
private readonly List<RemoteServerConfiguration> _servers;
public RemoteConfiguration(IConfiguration configuration)
{
Servers = new()
_servers = new();
configuration.Bind("servers", _servers);
}
public ImmutableList<IRemoteServerConfiguration> Servers => _servers.Cast<IRemoteServerConfiguration>().ToImmutableList();
public ImmutableList<IRemoteServerConfiguration> Query(string id)
{
"http://localhost:5063"
};
return _servers.Where(e => e.Id == id).Cast<IRemoteServerConfiguration>().ToImmutableList();
}
public List<string> Servers { get; }
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Connected.Configuration;
internal class RemoteServerConfiguration : IRemoteServerConfiguration
{
public string? Id { get; init; }
public string? Address { get; init; }
}

@ -1,10 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Connected</RootNamespace>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Connected</RootNamespace>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>$(AssemblyName)</Title>
<Authors>Tom PIT ltd</Authors>
<Copyright>2022 Tom PIT ltd</Copyright>
<PackageProjectUrl>https://git.tompit.com/Connected/Info</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>connected;platform;</PackageTags>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageOutputPath>$(OutputPath)</PackageOutputPath>
</PropertyGroup>
<ItemGroup>
@ -18,4 +29,14 @@
<ProjectReference Include="..\Connected\Connected.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
</Project>

@ -1,4 +1,5 @@
using Connected.Net;
using Connected.Configuration;
using Connected.Net;
using Connected.Startup;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;

@ -1,4 +1,5 @@
using Connected.Configuration;
using Microsoft.Extensions.Configuration;
namespace Connected.Net;
@ -7,7 +8,7 @@ namespace Connected.Net;
/// </summary>
internal class RemoteProviderService : IRemoteProviderService
{
public RemoteProviderService(IConfigurationService configuration)
public RemoteProviderService(IConfiguration configuration)
{
Configuration = configuration;
Balancer = new();
@ -16,7 +17,7 @@ internal class RemoteProviderService : IRemoteProviderService
}
private RoundRobin Balancer { get; }
private IConfigurationService Configuration { get; }
private IConfiguration Configuration { get; }
public string ProvideBaseUrl()
{
@ -30,7 +31,10 @@ internal class RemoteProviderService : IRemoteProviderService
private void Initialize()
{
foreach (var s in Configuration.Remote.Servers)
Balancer.Register(new RemoteDescriptor(s));
var remoteConfiguration = new RemoteConfiguration(Configuration.GetSection("remote"));
foreach (var s in remoteConfiguration.Servers)
if (!string.IsNullOrWhiteSpace(s.Address))
Balancer.Register(new RemoteDescriptor(s.Address));
}
}

@ -12,14 +12,16 @@
<Copyright>Tom PIT</Copyright>
<PackageProjectUrl>https://git.tompit.com/Connected/connected</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://git.tompit.com/Connected/connected</RepositoryUrl>
<RepositoryUrl>https://git.tompit.com/Connected/Connected</RepositoryUrl>
<PackageTags>connected;platform;</PackageTags>
<PackageReleaseNotes>First beta release</PackageReleaseNotes>
<PackageReleaseNotes></PackageReleaseNotes>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DocumentationFile>..\..\docs\api\connected.xml</DocumentationFile>
<PackageOutputPath>$(OutputPath)</PackageOutputPath>
<Version>$(VersionPrefix)$(VersionSuffix)</Version>
</PropertyGroup>
<ItemGroup>
@ -57,5 +59,4 @@
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
</Project>

Loading…
Cancel
Save