diff --git a/Needlework.Net.Core.Tests/LcuSchemaHandlerTest.cs b/Needlework.Net.Core.Tests/LcuSchemaHandlerTest.cs
deleted file mode 100644
index 62ab554..0000000
--- a/Needlework.Net.Core.Tests/LcuSchemaHandlerTest.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using Xunit.Abstractions;
-
-namespace Needlework.Net.Core.Tests;
-
-public class LcuSchemaHandlerTest
-{
- private readonly ITestOutputHelper _output;
-
- internal HttpClient HttpClient { get; } = new();
-
- public LcuSchemaHandlerTest(ITestOutputHelper output)
- {
- _output = output;
- }
-
- [Fact]
- public async Task PluginsTestAsync()
- {
- var reader = new LcuSchemaHandler(await Resources.GetOpenApiDocumentAsync(HttpClient));
-
- var plugins = reader.Plugins.Keys.ToList();
- foreach (var plugin in plugins)
- _output.WriteLine($"Plugin: {plugin}");
-
- Assert.True(plugins.Count > 0);
- }
-}
\ No newline at end of file
diff --git a/Needlework.Net.Core.Tests/Needlework.Net.Core.Tests.csproj b/Needlework.Net.Core.Tests/Needlework.Net.Core.Tests.csproj
deleted file mode 100644
index 48930a3..0000000
--- a/Needlework.Net.Core.Tests/Needlework.Net.Core.Tests.csproj
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- net8.0-windows
- enable
- enable
-
- false
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Needlework.Net.Core.Tests/ResourcesTest.cs b/Needlework.Net.Core.Tests/ResourcesTest.cs
deleted file mode 100644
index 22ef6a0..0000000
--- a/Needlework.Net.Core.Tests/ResourcesTest.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Xunit.Abstractions;
-
-namespace Needlework.Net.Core.Tests;
-
-public class ResourcesTest
-{
- private readonly ITestOutputHelper _output;
-
- internal HttpClient HttpClient { get; } = new();
-
- public ResourcesTest(ITestOutputHelper output)
- {
- _output = output;
- }
-
- [Fact]
- public async Task DocumentTestAsync()
- {
- var document = await Resources.GetOpenApiDocumentAsync(HttpClient);
-
- Assert.True(document.Info.Title == "LCU SCHEMA");
- }
-}
\ No newline at end of file
diff --git a/Needlework.Net.Core/Needlework.Net.Core.csproj b/Needlework.Net.Core/Needlework.Net.Core.csproj
deleted file mode 100644
index 9fcb20c..0000000
--- a/Needlework.Net.Core/Needlework.Net.Core.csproj
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- net8.0-windows
- enable
- enable
-
-
-
-
-
-
-
-
diff --git a/Needlework.Net.sln b/Needlework.Net.sln
index 44bbbb1..add6597 100644
--- a/Needlework.Net.sln
+++ b/Needlework.Net.sln
@@ -3,12 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Needlework.Net.Core", "Needlework.Net.Core\Needlework.Net.Core.csproj", "{B14E1B39-3C5A-400F-8148-CC3A4833CBC4}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Needlework.Net", "Needlework.Net\Needlework.Net.csproj", "{7388B579-2DC0-46D6-957A-6683D0FCF5D3}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Needlework.Net.Core.Tests", "Needlework.Net.Core.Tests\Needlework.Net.Core.Tests.csproj", "{0E08542E-6E3F-4825-9F9C-7D6275D6AEC5}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -18,17 +14,9 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {B14E1B39-3C5A-400F-8148-CC3A4833CBC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B14E1B39-3C5A-400F-8148-CC3A4833CBC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B14E1B39-3C5A-400F-8148-CC3A4833CBC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B14E1B39-3C5A-400F-8148-CC3A4833CBC4}.Release|Any CPU.Build.0 = Release|Any CPU
{7388B579-2DC0-46D6-957A-6683D0FCF5D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7388B579-2DC0-46D6-957A-6683D0FCF5D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7388B579-2DC0-46D6-957A-6683D0FCF5D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7388B579-2DC0-46D6-957A-6683D0FCF5D3}.Release|Any CPU.Build.0 = Release|Any CPU
- {0E08542E-6E3F-4825-9F9C-7D6275D6AEC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0E08542E-6E3F-4825-9F9C-7D6275D6AEC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0E08542E-6E3F-4825-9F9C-7D6275D6AEC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0E08542E-6E3F-4825-9F9C-7D6275D6AEC5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/Needlework.Net/Extensions/ServiceCollectionExtensions.cs b/Needlework.Net/Extensions/ServiceCollectionExtensions.cs
new file mode 100644
index 0000000..a2f50af
--- /dev/null
+++ b/Needlework.Net/Extensions/ServiceCollectionExtensions.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Needlework.Net.Extensions
+{
+ public static class ServiceCollectionExtensions
+ {
+ public static IServiceCollection AddSingletonsFromAssemblies(this ServiceCollection services)
+ {
+ var types = AppDomain.CurrentDomain.GetAssemblies()
+ .SelectMany(s => s.GetTypes())
+ .Where(p => !p.IsAbstract && typeof(T).IsAssignableFrom(p));
+
+ foreach (var type in types) services.AddSingleton(typeof(T), type);
+
+ return services;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Needlework.Net/Messages/DataReadyMessage.cs b/Needlework.Net/Messages/DataReadyMessage.cs
index 5505fab..a88168d 100644
--- a/Needlework.Net/Messages/DataReadyMessage.cs
+++ b/Needlework.Net/Messages/DataReadyMessage.cs
@@ -1,9 +1,9 @@
using CommunityToolkit.Mvvm.Messaging.Messages;
-using Needlework.Net.Core;
+using Needlework.Net.Models;
namespace Needlework.Net.Messages
{
- public class DataReadyMessage(LcuSchemaHandler handler) : ValueChangedMessage(handler)
+ public class DataReadyMessage(OpenApiDocumentWrapper wrapper) : ValueChangedMessage(wrapper)
{
}
}
diff --git a/Needlework.Net/Messages/DataRequestMessage.cs b/Needlework.Net/Messages/DataRequestMessage.cs
index fb248bf..1b44d1b 100644
--- a/Needlework.Net/Messages/DataRequestMessage.cs
+++ b/Needlework.Net/Messages/DataRequestMessage.cs
@@ -1,9 +1,9 @@
using CommunityToolkit.Mvvm.Messaging.Messages;
-using Needlework.Net.Core;
+using Needlework.Net.Models;
namespace Needlework.Net.Messages
{
- public class DataRequestMessage : RequestMessage
+ public class DataRequestMessage : RequestMessage
{
}
}
diff --git a/Needlework.Net/GithubRelease.cs b/Needlework.Net/Models/GithubRelease.cs
similarity index 89%
rename from Needlework.Net/GithubRelease.cs
rename to Needlework.Net/Models/GithubRelease.cs
index d1bb256..55f58d3 100644
--- a/Needlework.Net/GithubRelease.cs
+++ b/Needlework.Net/Models/GithubRelease.cs
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
-namespace Needlework.Net
+namespace Needlework.Net.Models
{
public class GithubRelease
{
diff --git a/Needlework.Net.Core/LcuSchemaHandler.cs b/Needlework.Net/Models/OpenApiDocumentWrapper.cs
similarity index 92%
rename from Needlework.Net.Core/LcuSchemaHandler.cs
rename to Needlework.Net/Models/OpenApiDocumentWrapper.cs
index ab910a8..8a8ccc5 100644
--- a/Needlework.Net.Core/LcuSchemaHandler.cs
+++ b/Needlework.Net/Models/OpenApiDocumentWrapper.cs
@@ -1,8 +1,9 @@
+using System.Collections.Generic;
using Microsoft.OpenApi.Models;
-namespace Needlework.Net.Core;
+namespace Needlework.Net.Models;
-public class LcuSchemaHandler
+public class OpenApiDocumentWrapper
{
internal OpenApiDocument OpenApiDocument { get; }
@@ -12,7 +13,7 @@ public class LcuSchemaHandler
public List Paths => [.. OpenApiDocument.Paths.Keys];
- public LcuSchemaHandler(OpenApiDocument openApiDocument)
+ public OpenApiDocumentWrapper(OpenApiDocument openApiDocument)
{
OpenApiDocument = openApiDocument;
var plugins = new SortedDictionary>();
@@ -68,5 +69,3 @@ public class LcuSchemaHandler
Plugins = plugins;
}
}
-
-public record PathOperation(string Method, string Path, OpenApiOperation Operation);
\ No newline at end of file
diff --git a/Needlework.Net/Models/PathOperation.cs b/Needlework.Net/Models/PathOperation.cs
new file mode 100644
index 0000000..7e5b914
--- /dev/null
+++ b/Needlework.Net/Models/PathOperation.cs
@@ -0,0 +1,5 @@
+using Microsoft.OpenApi.Models;
+
+namespace Needlework.Net.Models;
+
+public record PathOperation(string Method, string Path, OpenApiOperation Operation);
\ No newline at end of file
diff --git a/Needlework.Net.Core/Resources.cs b/Needlework.Net/Models/Resources.cs
similarity index 83%
rename from Needlework.Net.Core/Resources.cs
rename to Needlework.Net/Models/Resources.cs
index 94922d1..521eea4 100644
--- a/Needlework.Net.Core/Resources.cs
+++ b/Needlework.Net/Models/Resources.cs
@@ -1,7 +1,9 @@
-using Microsoft.OpenApi.Models;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Readers;
-namespace Needlework.Net.Core;
+namespace Needlework.Net.Models;
public static class Resources
{
diff --git a/Needlework.Net/Needlework.Net.csproj b/Needlework.Net/Needlework.Net.csproj
index 81a673b..93fd484 100644
--- a/Needlework.Net/Needlework.Net.csproj
+++ b/Needlework.Net/Needlework.Net.csproj
@@ -33,6 +33,8 @@
+
+
@@ -42,10 +44,6 @@
-
-
-
-
diff --git a/Needlework.Net/Program.cs b/Needlework.Net/Program.cs
index 3a05ce1..69f7fe5 100644
--- a/Needlework.Net/Program.cs
+++ b/Needlework.Net/Program.cs
@@ -1,5 +1,6 @@
using Avalonia;
using Microsoft.Extensions.DependencyInjection;
+using Needlework.Net.Extensions;
using Needlework.Net.Services;
using Needlework.Net.ViewModels;
using Projektanker.Icons.Avalonia;
@@ -36,13 +37,8 @@ class Program
builder.AddSingleton();
builder.AddSingleton();
- // Dynamically add ViewModels
- var types = AppDomain.CurrentDomain.GetAssemblies()
- .SelectMany(s => s.GetTypes())
- .Where(p => !p.IsAbstract && typeof(PageBase).IsAssignableFrom(p));
- foreach (var type in types)
- builder.AddSingleton(typeof(PageBase), type);
-
+ builder.AddSingletonsFromAssemblies();
+
builder.AddHttpClient();
var services = builder.BuildServiceProvider();
diff --git a/Needlework.Net/ViewModels/EndpointViewModel.cs b/Needlework.Net/ViewModels/EndpointViewModel.cs
index 33765d9..19fddba 100644
--- a/Needlework.Net/ViewModels/EndpointViewModel.cs
+++ b/Needlework.Net/ViewModels/EndpointViewModel.cs
@@ -3,7 +3,6 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;
using Needlework.Net.Messages;
using System;
-using System.Collections.Generic;
using System.Linq;
namespace Needlework.Net.ViewModels
diff --git a/Needlework.Net/ViewModels/MainWindowViewModel.cs b/Needlework.Net/ViewModels/MainWindowViewModel.cs
index 3dc7e95..cd7ca50 100644
--- a/Needlework.Net/ViewModels/MainWindowViewModel.cs
+++ b/Needlework.Net/ViewModels/MainWindowViewModel.cs
@@ -4,8 +4,8 @@ using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using FluentAvalonia.UI.Controls;
using Microsoft.OpenApi.Models;
-using Needlework.Net.Core;
using Needlework.Net.Messages;
+using Needlework.Net.Models;
using Needlework.Net.Services;
using System;
using System.Collections.Generic;
@@ -32,7 +32,7 @@ namespace Needlework.Net.ViewModels
public HttpClient HttpClient { get; }
public WindowService WindowService { get; }
- public LcuSchemaHandler? LcuSchemaHandler { get; set; }
+ public OpenApiDocumentWrapper? OpenApiDocumentWrapper { get; set; }
public OpenApiDocument? HostDocument { get; set; }
[ObservableProperty] private bool _isBusy = true;
@@ -105,8 +105,8 @@ namespace Needlework.Net.ViewModels
{
var document = await Resources.GetOpenApiDocumentAsync(HttpClient);
HostDocument = document;
- var handler = new LcuSchemaHandler(document);
- LcuSchemaHandler = handler;
+ var handler = new OpenApiDocumentWrapper(document);
+ OpenApiDocumentWrapper = handler;
WeakReferenceMessenger.Default.Send(new DataReadyMessage(handler));
IsBusy = false;
@@ -114,7 +114,7 @@ namespace Needlework.Net.ViewModels
public void Receive(DataRequestMessage message)
{
- message.Reply(LcuSchemaHandler!);
+ message.Reply(OpenApiDocumentWrapper!);
}
public void Receive(HostDocumentRequestMessage message)
diff --git a/Needlework.Net/ViewModels/PathOperationViewModel.cs b/Needlework.Net/ViewModels/PathOperationViewModel.cs
index 5eaf7e7..cfb748d 100644
--- a/Needlework.Net/ViewModels/PathOperationViewModel.cs
+++ b/Needlework.Net/ViewModels/PathOperationViewModel.cs
@@ -3,8 +3,8 @@ using BlossomiShymae.GrrrLCU;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
-using Needlework.Net.Core;
using Needlework.Net.Messages;
+using Needlework.Net.Models;
using System;
using System.Net.Http;
using System.Text;