Skip to content

Commit

Permalink
refactor: adjust to new project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ArachisH committed Mar 28, 2024
1 parent 3b00647 commit 04d3a85
Show file tree
Hide file tree
Showing 25 changed files with 41 additions and 45 deletions.
5 changes: 2 additions & 3 deletions Tanji.CLI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.Runtime.InteropServices;

using Tanji.Core;
using Tanji.Core.Network;
using Tanji.Core.Services;
using Tanji.Core.Habbo.Canvas;
using Tanji.Core.Configuration;
using Tanji.Infrastructure.Services;
using Tanji.Infrastructure.Configuration;

using Eavesdrop;

Expand Down
6 changes: 0 additions & 6 deletions Tanji.Core/Tanji.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@
<ItemGroup>
<PackageReference Include="Eavesdrop" Version="1.3.0" />
<PackageReference Include="Hypo.Flazzy" Version="0.4.0" />
<PackageReference Include="System.IO.Pipelines" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.2.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

using CommunityToolkit.HighPerformance.Buffers;

namespace Tanji.Core.Configuration;
namespace Tanji.Infrastructure.Configuration;

internal sealed class PostConfigureTanjiOptions : IPostConfigureOptions<TanjiOptions>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Tanji.Core.Json;
using Tanji.Core.Habbo.Canvas;

namespace Tanji.Core.Configuration;
namespace Tanji.Infrastructure.Configuration;

public readonly record struct PlatformPaths
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Tanji.Core.Habbo;
using Tanji.Core.Habbo.Canvas;

namespace Tanji.Core.Services;
namespace Tanji.Infrastructure.Services;

public interface IClientHandlerService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.ObjectModel;

using Tanji.Core.Network;
using Tanji.Infrastructure.Services;

namespace Tanji.Core.Services;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Tanji.Core.Habbo.Network;

namespace Tanji.Core.Services;
namespace Tanji.Infrastructure.Services;

public interface IPacketMiddlemanService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Tanji.Core.Services;
namespace Tanji.Infrastructure.Services;

public interface IWebInterceptionService
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

using Tanji.Core;
using Tanji.Core.Json;
using Tanji.Core.Habbo;
using Tanji.Core.Habbo.Canvas;
using Tanji.Core.Configuration;
using Tanji.Core.Json.Converters;
using Tanji.Core.Habbo.Canvas.Flash;
using Tanji.Infrastructure.Configuration;

using Flazzy.Tools;

using CommunityToolkit.HighPerformance;
using CommunityToolkit.HighPerformance.Buffers;

namespace Tanji.Core.Services;
namespace Tanji.Infrastructure.Services.Implementations;

public sealed class ClientHandlerService : IClientHandlerService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Net;
using System.Collections.ObjectModel;

using Tanji.Core;
using Tanji.Core.Network;
using Tanji.Core.Habbo.Canvas;
using Tanji.Core.Habbo.Network.Buffers;
Expand All @@ -10,15 +11,15 @@

using CommunityToolkit.HighPerformance.Buffers;

namespace Tanji.Core.Services;
namespace Tanji.Infrastructure.Services.Implementations;

public sealed class ConnectionHandlerService : IConnectionHandlerService<PacketMiddlemanService>
public sealed class ConnectionHandlerService : IConnectionHandlerService
{
private readonly PacketMiddlemanService _packetMiddleman;
private readonly ILogger<ConnectionHandlerService> _logger;
private readonly IClientHandlerService _clientHandler;

public ObservableCollection<HConnection<PacketMiddlemanService>> Connections { get; } = [];
public ObservableCollection<HConnection> Connections { get; } = [];

public ConnectionHandlerService(ILogger<ConnectionHandlerService> logger,
IClientHandlerService clientHandler,
Expand All @@ -29,15 +30,15 @@ public sealed class ConnectionHandlerService : IConnectionHandlerService<PacketM
_packetMiddleman = packetMiddleman;
}

public async Task<HConnection<PacketMiddlemanService>> LaunchAndInterceptConnectionAsync(string ticket, HConnectionContext context, CancellationToken cancellationToken = default)
public async Task<HConnection> LaunchAndInterceptConnectionAsync(string ticket, HConnectionContext context, CancellationToken cancellationToken = default)
{
if (string.IsNullOrWhiteSpace(ticket))
{
_logger.LogError("Ticket should be provided when attempting to launch the client.");
ThrowHelper.ThrowArgumentNullException(nameof(ticket));
}

var connection = new HConnection<PacketMiddlemanService>(_packetMiddleman);
var connection = new HConnection();
ValueTask interceptLocalConnectionTask = connection.InterceptLocalConnectionAsync(context, cancellationToken);

_ = _clientHandler.LaunchClient(context.Platform, ticket, context.ClientPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using Microsoft.Extensions.Logging;

namespace Tanji.Core.Services;
namespace Tanji.Infrastructure.Services.Implementations;

public class PacketMiddlemanService : IPacketMiddlemanService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Threading.Channels;

using Tanji.Core.Habbo;
using Tanji.Core.Configuration;
using Tanji.Infrastructure.Configuration;

using Eavesdrop;

Expand All @@ -10,7 +10,7 @@

using CommunityToolkit.HighPerformance;

namespace Tanji.Core.Services;
namespace Tanji.Infrastructure.Services.Implementations;

public sealed class WebInterceptionService : IWebInterceptionService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Tanji.Core.Services;
using Tanji.Core.ViewModels;
using Tanji.Core.Configuration;
using Tanji.Infrastructure.Services.Implementations;

using Tanji.Infrastructure.ViewModels;
using Tanji.Infrastructure.Configuration;

using Microsoft.Extensions.Options;
using Microsoft.Extensions.DependencyInjection;

namespace Tanji.Core;
namespace Tanji.Infrastructure.Services;

public static class ServiceCollectionExtensions
{
Expand All @@ -20,7 +21,7 @@ public static IServiceCollection AddTanjiCore(this IServiceCollection services)
services.AddSingleton<IClientHandlerService, ClientHandlerService>();

services.AddSingleton<PacketMiddlemanService>();
services.AddSingleton<IConnectionHandlerService<PacketMiddlemanService>, ConnectionHandlerService>();
services.AddSingleton<IConnectionHandlerService, ConnectionHandlerService>();

// Add view-models
services.AddSingleton<ConnectionViewModel>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Tanji.Core.Services;
using Tanji.Core.Habbo.Network;
using Tanji.Core.Habbo.Network;
using Tanji.Infrastructure.Services;

using CommunityToolkit.Mvvm.ComponentModel;

namespace Tanji.Core.ViewModels;
namespace Tanji.Infrastructure.ViewModels;

public partial class ConnectionViewModel : ObservableObject
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel;

namespace Tanji.Core.ViewModels;
namespace Tanji.Infrastructure.ViewModels;

public partial class ExtensionsViewModel : ObservableObject
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel;

namespace Tanji.Core.ViewModels;
namespace Tanji.Infrastructure.ViewModels;

public partial class InjectionViewModel : ObservableObject
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel;

namespace Tanji.Core.ViewModels;
namespace Tanji.Infrastructure.ViewModels;

public partial class SettingsViewModel : ObservableObject
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel;

namespace Tanji.Core.ViewModels;
namespace Tanji.Infrastructure.ViewModels;

public partial class ToolboxViewModel : ObservableObject
{
Expand Down
2 changes: 1 addition & 1 deletion Tanji/Controls/PageControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Windows.Forms;
using System.ComponentModel;

using Tanji.Core.ViewModels;
using Tanji.Infrastructure.ViewModels;

using Microsoft.Extensions.DependencyInjection;

Expand Down
5 changes: 2 additions & 3 deletions Tanji/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

using Tanji.Views;
using Tanji.Utilities;

using Tanji.Core;
using Tanji.Core.Configuration;
using Tanji.Infrastructure.Services;
using Tanji.Infrastructure.Configuration;

var builder = Host.CreateApplicationBuilder(args);

Expand Down
2 changes: 1 addition & 1 deletion Tanji/Views/Pages/ConnectionView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tanji/Views/Pages/ExtensionsView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tanji/Views/Pages/InjectionView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tanji/Views/Pages/SettingsView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tanji/Views/Pages/ToolboxView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 04d3a85

Please sign in to comment.