Skip to content

Commit

Permalink
[Core] Post Config through .ctors
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Oct 24, 2023
1 parent 6b0d094 commit 21dbfcb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions Lagrange.Core/Internal/Context/ContextCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,20 @@ internal class ContextCollection
public BotKeystore Keystore { get; }
public BotAppInfo AppInfo { get; }
public BotDeviceInfo Device { get; }
public BotConfig Config { get; }

public TaskScheduler Scheduler { get; }
public EventInvoker Invoker { get; }

public ContextCollection(BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, BotConfig config,
EventInvoker invoker, TaskScheduler scheduler)
{
Packet = new PacketContext(this, keystore, appInfo, device);
Packet = new PacketContext(this, keystore, appInfo, device, config);
Socket = new SocketContext(this, keystore, appInfo, device, config);
Service = new ServiceContext(this, keystore, appInfo, device);
Business = new BusinessContext(this, keystore, appInfo, device);
Log = new LogContext(this, keystore, appInfo, device, invoker);
Highway = new HighwayContext(this, keystore, appInfo, device);

Config = config;
Keystore = keystore;
AppInfo = appInfo;
Device = device;
Expand Down
4 changes: 2 additions & 2 deletions Lagrange.Core/Internal/Context/PacketContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ internal class PacketContext : ContextBase

private readonly ConcurrentDictionary<uint, TaskCompletionSource<SsoPacket>> _pendingTasks;

public PacketContext(ContextCollection collection, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device)
public PacketContext(ContextCollection collection, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, BotConfig config)
: base(collection, keystore, appInfo, device)
{
_signProvider = Collection.Config.CustomSignProvider ?? appInfo.Os switch
_signProvider = config.CustomSignProvider ?? appInfo.Os switch
{
"Windows" => new WindowsSigner(),
"Mac" => new MacSigner(),
Expand Down

0 comments on commit 21dbfcb

Please sign in to comment.