diff --git a/Core/Annotations/Injectable.cs b/Core/Annotations/Injectable.cs index b29b7af0..8bb82dc5 100644 --- a/Core/Annotations/Injectable.cs +++ b/Core/Annotations/Injectable.cs @@ -1,6 +1,6 @@ namespace Core.Annotations; -[AttributeUsage(AttributeTargets.Class)] +[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] public class Injectable(InjectionType injectionType = InjectionType.Scoped, Type? type = null, int typePriority = int.MaxValue) : Attribute { public InjectionType InjectionType { get; set; } = injectionType; @@ -13,4 +13,4 @@ public enum InjectionType Singleton, Transient, Scoped -} \ No newline at end of file +} diff --git a/Core/Callbacks/DialogCallbacks.cs b/Core/Callbacks/DialogCallbacks.cs index b3388096..8cd69882 100644 --- a/Core/Callbacks/DialogCallbacks.cs +++ b/Core/Callbacks/DialogCallbacks.cs @@ -4,13 +4,11 @@ using Core.DI; using Core.Models.Eft.Common; using Core.Models.Eft.Common.Request; using Core.Models.Eft.Dialog; -using Core.Models.Eft.HttpResponse; -using Core.Models.Eft.Profile; using Core.Utils; namespace Core.Callbacks; -[Injectable] +[Injectable(TypePriority = OnUpdateOrder.DialogCallbacks)] public class DialogCallbacks : OnUpdate { protected HashUtil _hashUtil; diff --git a/Core/Callbacks/GameCallbacks.cs b/Core/Callbacks/GameCallbacks.cs index cf5324cd..a31e7f59 100644 --- a/Core/Callbacks/GameCallbacks.cs +++ b/Core/Callbacks/GameCallbacks.cs @@ -10,7 +10,7 @@ using Core.Utils; namespace Core.Callbacks; -[Injectable] +[Injectable(TypePriority = OnLoadOrder.GameCallbacks)] public class GameCallbacks : OnLoad { protected HttpResponseUtil _httpResponseUtil; diff --git a/Core/Callbacks/HandbookCallbacks.cs b/Core/Callbacks/HandbookCallbacks.cs index 749eb80e..01b482a3 100644 --- a/Core/Callbacks/HandbookCallbacks.cs +++ b/Core/Callbacks/HandbookCallbacks.cs @@ -4,7 +4,7 @@ using Core.DI; namespace Core.Callbacks; -[Injectable] +[Injectable(TypePriority = OnLoadOrder.HandbookCallbacks)] public class HandbookCallbacks : OnLoad { protected HandBookController _handBookController; diff --git a/Core/Callbacks/HttpCallbacks.cs b/Core/Callbacks/HttpCallbacks.cs index 7aa6f9dc..ca07ada3 100644 --- a/Core/Callbacks/HttpCallbacks.cs +++ b/Core/Callbacks/HttpCallbacks.cs @@ -5,7 +5,7 @@ using Core.Servers; namespace Core.Callbacks; -[Injectable(InjectionType.Singleton, typePriority: 1)] +[Injectable(InjectionType.Singleton, typePriority: OnLoadOrder.HttpCallbacks)] public class HttpCallbacks : OnLoad { private readonly HttpServer _httpServer; @@ -31,4 +31,4 @@ public class HttpCallbacks : OnLoad { return ""; } -} \ No newline at end of file +} diff --git a/Core/Callbacks/ModCallbacks.cs b/Core/Callbacks/ModCallbacks.cs index feca9d59..faa1bce6 100644 --- a/Core/Callbacks/ModCallbacks.cs +++ b/Core/Callbacks/ModCallbacks.cs @@ -9,7 +9,7 @@ using ILogger = Core.Models.Utils.ILogger; namespace Core.Callbacks; -[Injectable] +[Injectable(TypePriority = OnLoadOrder.ModCallbacks)] public class ModCallbacks : OnLoad { protected ILogger _logger; diff --git a/Core/Callbacks/PresetCallbacks.cs b/Core/Callbacks/PresetCallbacks.cs index f81ee623..e8be5321 100644 --- a/Core/Callbacks/PresetCallbacks.cs +++ b/Core/Callbacks/PresetCallbacks.cs @@ -4,7 +4,7 @@ using Core.DI; namespace Core.Callbacks; -[Injectable] +[Injectable(TypePriority = OnLoadOrder.PresetCallbacks)] public class PresetCallbacks : OnLoad { protected PresetController _presetController; diff --git a/Core/Callbacks/RagfairCallbacks.cs b/Core/Callbacks/RagfairCallbacks.cs index 9a20eaed..22c8f0f8 100644 --- a/Core/Callbacks/RagfairCallbacks.cs +++ b/Core/Callbacks/RagfairCallbacks.cs @@ -13,7 +13,7 @@ using Core.Utils; namespace Core.Callbacks; -[Injectable] +[Injectable(TypePriority = OnLoadOrder.RagfairCallbacks)] public class RagfairCallbacks : OnLoad, OnUpdate { protected HttpResponseUtil _httpResponseUtil; diff --git a/Core/Callbacks/SaveCallbacks.cs b/Core/Callbacks/SaveCallbacks.cs index 28d881b0..4d9d962a 100644 --- a/Core/Callbacks/SaveCallbacks.cs +++ b/Core/Callbacks/SaveCallbacks.cs @@ -7,7 +7,7 @@ using Core.Services; namespace Core.Callbacks; -[Injectable] +[Injectable(TypePriority = OnLoadOrder.SaveCallbacks)] public class SaveCallbacks : OnLoad, OnUpdate { protected SaveServer _saveServer; diff --git a/Core/Callbacks/TraderCallbacks.cs b/Core/Callbacks/TraderCallbacks.cs index 8b7e4cfa..928c9262 100644 --- a/Core/Callbacks/TraderCallbacks.cs +++ b/Core/Callbacks/TraderCallbacks.cs @@ -11,7 +11,7 @@ using Core.Utils; namespace Core.Callbacks; -[Injectable] +[Injectable(TypePriority = OnLoadOrder.TraderCallbacks)] public class TraderCallbacks : OnLoad, OnUpdate { protected HttpResponseUtil _httpResponseUtil; diff --git a/Core/Context/ContextVariableType.cs b/Core/Context/ContextVariableType.cs index c6334931..878a0b3b 100644 --- a/Core/Context/ContextVariableType.cs +++ b/Core/Context/ContextVariableType.cs @@ -17,5 +17,6 @@ public enum ContextVariableType /** Data returned from client request object from endLocalRaid() */ TRANSIT_INFO = 5, - APP_BUILDER = 6 -} \ No newline at end of file + APP_BUILDER = 6, + LOADED_MOD_ASSEMBLIES = 6 +} diff --git a/Core/DI/OnLoadOrder.cs b/Core/DI/OnLoadOrder.cs new file mode 100644 index 00000000..9e9b75d7 --- /dev/null +++ b/Core/DI/OnLoadOrder.cs @@ -0,0 +1,16 @@ +namespace Core.DI; + +public static class OnLoadOrder +{ + public const int Database = 0; + public const int PostDBModLoader = 1; + public const int HandbookCallbacks = 2; + public const int HttpCallbacks = 3; + public const int PresetCallbacks = 4; + public const int SaveCallbacks = 5; + public const int TraderCallbacks = 6; + public const int RagfairPriceService = 7; + public const int RagfairCallbacks = 8; + public const int ModCallbacks = 9; + public const int GameCallbacks = 10; +} diff --git a/Core/DI/OnUpdateOrder.cs b/Core/DI/OnUpdateOrder.cs new file mode 100644 index 00000000..961b7aec --- /dev/null +++ b/Core/DI/OnUpdateOrder.cs @@ -0,0 +1,11 @@ +namespace Core.DI; + +public static class OnUpdateOrder +{ + public const int DialogCallbacks = 0; + public const int PostDBModLoader = 1; + public const int HandbookCallbacks = 2; + public const int HttpCallbacks = 3; + public const int PresetCallbacks = 4; + public const int SaveCallbacks = 5; +} diff --git a/Core/Models/External/IPostDBLoadMod.cs b/Core/Models/External/IPostDBLoadMod.cs new file mode 100644 index 00000000..c0c2adfc --- /dev/null +++ b/Core/Models/External/IPostDBLoadMod.cs @@ -0,0 +1,6 @@ +namespace Core.Models.External; + +public interface IPostDBLoadMod +{ + void PostDBLoad(); +} diff --git a/Core/Models/External/IPostSptLoadMod.cs b/Core/Models/External/IPostSptLoadMod.cs new file mode 100644 index 00000000..dbd05e7f --- /dev/null +++ b/Core/Models/External/IPostSptLoadMod.cs @@ -0,0 +1,6 @@ +namespace Core.Models.External; + +public interface IPostSptLoadMod +{ + void PostSptLoad(); +} diff --git a/Core/Models/External/IPreSptLoadMod.cs b/Core/Models/External/IPreSptLoadMod.cs new file mode 100644 index 00000000..f237299a --- /dev/null +++ b/Core/Models/External/IPreSptLoadMod.cs @@ -0,0 +1,6 @@ +namespace Core.Models.External; + +public interface IPreSptLoadMod +{ + void PreSptLoad(); +} diff --git a/Core/Utils/DatabaseImporter.cs b/Core/Utils/DatabaseImporter.cs index 9e4cd55b..a146b08d 100644 --- a/Core/Utils/DatabaseImporter.cs +++ b/Core/Utils/DatabaseImporter.cs @@ -10,7 +10,7 @@ using ILogger = Core.Models.Utils.ILogger; namespace Core.Utils; -[Injectable(InjectionType.Singleton, typePriority: 0)] +[Injectable(InjectionType.Singleton, TypePriority = OnLoadOrder.Database)] public class DatabaseImporter : OnLoad { private object hashedFile; diff --git a/Server/Program.cs b/Server/Program.cs index a74760ec..b0c2839c 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -18,13 +18,13 @@ public static class Program try { - var serviceProvider = builder.Services.BuildServiceProvider(); var watermark = serviceProvider.GetService(); watermark.Initialize(); // TODO: var preSptModLoader = serviceProvider.GetService(); var app = serviceProvider.GetService(); var appContext = serviceProvider.GetService(); + appContext.AddValue(ContextVariableType.LOADED_MOD_ASSEMBLIES, assemblies); appContext.AddValue(ContextVariableType.APP_BUILDER, builder); app.Load().Wait(); }