Compare commits

..

No commits in common. 'develop' and 'main' have entirely different histories.

1
.gitignore vendored

@ -423,7 +423,6 @@ FodyWeavers.xsd
!/build !/build
!/docs !/docs
!/examples !/examples
!/dependencies
!/src !/src
!/tests !/tests
!/tools !/tools

8
.gitmodules vendored

@ -1,8 +0,0 @@
[submodule "dependencies/Connected"]
path = dependencies/Connected
url = https://git.tompit.com/Connected/Connected.git
branch = develop
[submodule "dependencies/Connected.Components"]
path = dependencies/Connected.Components
url = https://git.tompit.com/Connected/Connected.Components.git
branch = features/rewrite/main

@ -1,43 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.32916.344
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.UI", "src\Connected.UI\Connected.UI.csproj", "{52D89174-140B-4017-8B52-B83FA936D809}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{0A1EBC0F-0567-41FB-9187-7DE1722FAB4E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.Client", "dependencies\Connected\src\Connected.Client\Connected.Client.csproj", "{74A5C323-008A-4928-900B-9FC6559FF1AF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.Components", "dependencies\Connected.Components\src\Connected.Components\Connected.Components.csproj", "{78850429-4E96-46CC-A099-7BF7D97DEA3A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{52D89174-140B-4017-8B52-B83FA936D809}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52D89174-140B-4017-8B52-B83FA936D809}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52D89174-140B-4017-8B52-B83FA936D809}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52D89174-140B-4017-8B52-B83FA936D809}.Release|Any CPU.Build.0 = Release|Any CPU
{74A5C323-008A-4928-900B-9FC6559FF1AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74A5C323-008A-4928-900B-9FC6559FF1AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74A5C323-008A-4928-900B-9FC6559FF1AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74A5C323-008A-4928-900B-9FC6559FF1AF}.Release|Any CPU.Build.0 = Release|Any CPU
{78850429-4E96-46CC-A099-7BF7D97DEA3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78850429-4E96-46CC-A099-7BF7D97DEA3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78850429-4E96-46CC-A099-7BF7D97DEA3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78850429-4E96-46CC-A099-7BF7D97DEA3A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{74A5C323-008A-4928-900B-9FC6559FF1AF} = {0A1EBC0F-0567-41FB-9187-7DE1722FAB4E}
{78850429-4E96-46CC-A099-7BF7D97DEA3A} = {0A1EBC0F-0567-41FB-9187-7DE1722FAB4E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4BE29712-DF74-4798-8F2E-92D7446D2465}
EndGlobalSection
EndGlobal

@ -1,22 +0,0 @@
@echo off
SET root=%cd%
echo "Syncing submodules"
git submodule sync
git submodule update --init --remote
echo "Submodules up to date"
FOR /F "delims=" %%a IN ('DIR "../dependencies" /A:d /B') DO (
echo Handling %%a
cd ../dependencies/%%a/build
echo %cd%
IF EXIST init.bat (
echo "found init.bat"
call init
)
cd %root%
)
cd ../
dotnet build

@ -1 +0,0 @@
Subproject commit dd40532a0ff03237407de9635c7211c5e1af5807

@ -1 +0,0 @@
Subproject commit a9e0968740c970e01fbef1d434f5802511ac138f

@ -1,23 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.*-*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\dependencies\Connected.Components\src\Connected.Components\Connected.Components.csproj" />
<ProjectReference Include="..\..\dependencies\Connected\src\Connected.Client\Connected.Client.csproj" />
</ItemGroup>
</Project>

@ -1,63 +0,0 @@
using Connected.Middleware;
using Connected.Startup;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace Connected;
public static class Instance
{
public static WebAssemblyHost Host { get; private set; } = default!;
private static IServiceProvider ServiceProvider { get; set; } = default!;
internal static T? GetService<T>()
{
return ServiceProvider.GetService<T>();
}
public static async Task Start<TApp>(List<IStartup> startups, Dictionary<string, string> args) where TApp : IComponent
{
var builder = WebAssemblyHostBuilder.CreateDefault(UnpackArguments(args));
builder.RootComponents.Add<TApp>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddHttpClient();
builder.Services.AddSingleton(typeof(IComponentMiddlewareService), typeof(ComponentMiddlewareService));
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
foreach (var startup in startups)
await startup.ConfigureServices(builder.Services);
Host = builder.Build();
foreach (var startup in startups)
await startup.Configure(Host);
await Host.RunAsync();
}
private static string[] UnpackArguments(Dictionary<string, string> args)
{
var result = new string[args.Count];
for (var i = 0; i < args.Count; i++)
{
var arg = args.ElementAt(i);
result[i] = string.IsNullOrWhiteSpace(arg.Value) ? arg.Key : $"{arg.Key}={arg.Value}";
}
return result;
}
public static void UseMiddlewareComponent<TMiddleware, TComponent>(this WebAssemblyHost app)
{
if (app.Services.GetService<IComponentMiddlewareService>() is not IComponentMiddlewareService service)
throw new NullReferenceException(nameof(IComponentMiddlewareService));
service.Add<TMiddleware, TComponent>();
}
}

@ -1,9 +0,0 @@
@inherits LayoutComponentBase
<HeadContent>
<link rel="stylesheet" href="_content/Connected.UI/Components.min.css" />
<link rel="stylesheet" href="_content/Connected.UI/Styles.min.css" />
</HeadContent>
@Body

@ -1,42 +0,0 @@
using System.Collections.Concurrent;
namespace Connected.Middleware;
internal class ComponentMiddlewareService : IComponentMiddlewareService
{
public ComponentMiddlewareService()
{
Middleware = new();
}
private ConcurrentDictionary<string, List<Type>> Middleware { get; }
public void Add<TMiddleware, TComponent>()
{
var componentName = typeof(TComponent).FullName;
if (string.IsNullOrEmpty(componentName))
throw new ArgumentException(null, nameof(TMiddleware));
if (Middleware.TryGetValue(componentName, out List<Type>? items))
{
//TODO: sort by priority so multiple inheritance would work
items.Add(typeof(TMiddleware));
}
else
Middleware.TryAdd(componentName, new List<Type> { typeof(TMiddleware) });
}
public Type? Select<TComponent>()
{
var typeName = typeof(TComponent).FullName;
if (string.IsNullOrEmpty(typeName))
throw new ArgumentException(null, nameof(TComponent));
if (Middleware.TryGetValue(typeName, out List<Type>? items) && items is not null && items.Any())
return items[0];
return null;
}
}

@ -1,8 +0,0 @@
namespace Connected.Middleware;
public interface IComponentMiddlewareService
{
void Add<TMiddleware, TComponent>();
Type? Select<TComponent>();
}

@ -1,29 +0,0 @@
using Connected.Middleware;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Logging;
namespace Connected.Components;
public abstract class UIComposition : ComponentBase
{
private ILogger _logger;
[Inject]
private ILoggerFactory LoggerFactory { get; set; } = default!;
[Inject]
private IComponentMiddlewareService? MiddlewareService { get; set; }
protected ILogger Logger => _logger ??= LoggerFactory.CreateLogger(GetType());
protected Type ResolveComponent<TComponent>()
{
if (MiddlewareService is null)
return typeof(TComponent);
if (MiddlewareService.Select<TComponent>() is Type type)
return type;
return typeof(TComponent);
}
}
Loading…
Cancel
Save