Enhance dictionary safety with SafeGet, SafeSet, and SafeRemove methods. Adjust IWebContext and related tests to support nullable value types in dictionary operations. Refactor GetRequestParameter for clarity and consistency.

This commit is contained in:
2025-07-29 02:05:28 +02:00
parent bab8898841
commit b7b7c472af
12 changed files with 55 additions and 34 deletions

View File

@@ -34,16 +34,16 @@ public class AspnetCoreWebContext : IWebContext
}
private Dictionary<string, string>? _requestCookies;
private Dictionary<string, string?>? _requestCookies;
public Dictionary<string, string> RequestCookies
public Dictionary<string, string?> RequestCookies
{
get
{
if (_requestCookies == null)
{
_requestCookies = _context.Request.Cookies
.ToDictionary(p => p.Key, p => p.Value);
.ToDictionary(p => p.Key, p => (string?)p.Value);
}
return _requestCookies;