diff --git a/Core/Callbacks/BotCallbacks.cs b/Core/Callbacks/BotCallbacks.cs index c99a47fd..537db7fa 100644 --- a/Core/Callbacks/BotCallbacks.cs +++ b/Core/Callbacks/BotCallbacks.cs @@ -1,4 +1,4 @@ -using Core.Annotations; +using Core.Annotations; using Core.Context; using Core.Controllers; using Core.Models.Eft.Bot; @@ -60,7 +60,7 @@ public class BotCallbacks if (difficulty == "core") return _httpResponseUtil.NoBody(_botController.GetBotCoreDifficulty()); - var raidConfig = (GetRaidConfigurationRequestData)_applicationContext.GetLatestValue(ContextVariableType.RAID_CONFIGURATION)?.Value; + var raidConfig = _applicationContext.GetLatestValue(ContextVariableType.RAID_CONFIGURATION)?.GetValue(); return _httpResponseUtil.NoBody(_botController.GetBotDifficulty(type, difficulty, raidConfig)); } diff --git a/Core/Callbacks/HttpCallbacks.cs b/Core/Callbacks/HttpCallbacks.cs index 6922ce0d..d132035f 100644 --- a/Core/Callbacks/HttpCallbacks.cs +++ b/Core/Callbacks/HttpCallbacks.cs @@ -1,4 +1,4 @@ -using Core.Annotations; +using Core.Annotations; using Core.Context; using Core.DI; using Core.Servers; @@ -18,7 +18,7 @@ public class HttpCallbacks : OnLoad public async Task OnLoad() { - _httpServer.Load((WebApplicationBuilder) _applicationContext.GetLatestValue(ContextVariableType.APP_BUILDER).Value); + _httpServer.Load( _applicationContext.GetLatestValue(ContextVariableType.APP_BUILDER).GetValue()); _applicationContext.ClearValues(ContextVariableType.APP_BUILDER); } diff --git a/Core/Context/ContextVariable.cs b/Core/Context/ContextVariable.cs index 4f5e199b..7c3b9280 100644 --- a/Core/Context/ContextVariable.cs +++ b/Core/Context/ContextVariable.cs @@ -1,8 +1,29 @@ -namespace Core.Context; +namespace Core.Context; -public class ContextVariable(object value, ContextVariableType contextVariableType) +public class ContextVariable { - public object Value { get; } = value; - public DateTime Timestamp { get; } = DateTime.Now; - public ContextVariableType Type { get; } = contextVariableType; -} \ No newline at end of file + private readonly object _value; + private readonly ContextVariableType _internalType; + private readonly DateTime _timestamp; + + public ContextVariable(object value, ContextVariableType contextVariableInternalType) + { + _value = value; + _timestamp = DateTime.Now; + _internalType = contextVariableInternalType; + } + + public T GetValue() { + return (T)_value; + } + + public DateTime GetTimestamp() + { + return _timestamp; + } + + public ContextVariableType GetContextType() + { + return _internalType; + } +}