From cd13adc61fa3cd43bf3fa991e336e5b5d0b6a6d3 Mon Sep 17 00:00:00 2001 From: Maurits van der Schee Date: Sat, 27 Aug 2022 00:17:44 +0200 Subject: [PATCH] update --- Maussoft.Mvc.csproj | 2 +- ViewRouter.cs | 1 - WebContext.cs | 12 ++++-------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Maussoft.Mvc.csproj b/Maussoft.Mvc.csproj index ee9a690..c84ddc3 100644 --- a/Maussoft.Mvc.csproj +++ b/Maussoft.Mvc.csproj @@ -2,7 +2,7 @@ net6.0 - 0.9.2 + 0.9.3 LICENSE README.md mevdschee diff --git a/ViewRouter.cs b/ViewRouter.cs index 322b70a..5e75c2e 100644 --- a/ViewRouter.cs +++ b/ViewRouter.cs @@ -16,7 +16,6 @@ public ViewRouter(string viewNamespace) private string Invoke(WebContext context, Type routedClass) { - Console.WriteLine(routedClass.FullName); View view = Activator.CreateInstance(routedClass) as View; if (view == null) { diff --git a/WebContext.cs b/WebContext.cs index 3b2841b..e21235f 100644 --- a/WebContext.cs +++ b/WebContext.cs @@ -5,7 +5,7 @@ using System.Web; using System.Collections.Generic; using System.Collections.Specialized; -using System.Dynamic; +using System.Numerics; using System.Security.Cryptography; using System.Text.Json; @@ -70,10 +70,9 @@ public void StartSession(Boolean readOnly) } this.sessionStream = WaitForFile(this.sessionSavePath + SessionIdentifier, FileMode.OpenOrCreate, readOnly ? FileAccess.Read : FileAccess.ReadWrite, FileShare.Read); - if (this.sessionStream.Length == 0) { - Session = new TSession(); + this.Session = new TSession(); var bytes = JsonSerializer.SerializeToUtf8Bytes(Session); sessionHashCode = ComputeHash(bytes); } @@ -81,7 +80,7 @@ public void StartSession(Boolean readOnly) { byte[] bytes = new byte[this.sessionStream.Length]; this.sessionStream.Read(bytes, 0, bytes.Length); - Session = JsonSerializer.Deserialize(bytes); + this.Session = JsonSerializer.Deserialize(bytes); sessionHashCode = ComputeHash(bytes); } @@ -95,15 +94,12 @@ public void StartSession(Boolean readOnly) private static int ComputeHash(params byte[] data) { - var hash = new HashCode(); - hash.AddBytes(data); - return hash.ToHashCode(); + return new BigInteger(data).GetHashCode(); } public void WriteSession() { var bytes = JsonSerializer.SerializeToUtf8Bytes(Session); - var newSessionHashCode = ComputeHash(bytes); if (newSessionHashCode != this.sessionHashCode)