Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mevdschee committed Aug 26, 2022
1 parent ff8e0a9 commit cd13adc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Maussoft.Mvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<PackageVersion>0.9.2</PackageVersion>
<PackageVersion>0.9.3</PackageVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Authors>mevdschee</Authors>
Expand Down
1 change: 0 additions & 1 deletion ViewRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public ViewRouter(string viewNamespace)

private string Invoke(WebContext<TSession> context, Type routedClass)
{
Console.WriteLine(routedClass.FullName);
View<TSession> view = Activator.CreateInstance(routedClass) as View<TSession>;
if (view == null)
{
Expand Down
12 changes: 4 additions & 8 deletions WebContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -70,18 +70,17 @@ 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<TSession>(Session);
sessionHashCode = ComputeHash(bytes);
}
else
{
byte[] bytes = new byte[this.sessionStream.Length];
this.sessionStream.Read(bytes, 0, bytes.Length);
Session = JsonSerializer.Deserialize<TSession>(bytes);
this.Session = JsonSerializer.Deserialize<TSession>(bytes);
sessionHashCode = ComputeHash(bytes);
}

Expand All @@ -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<TSession>(Session);

var newSessionHashCode = ComputeHash(bytes);

if (newSessionHashCode != this.sessionHashCode)
Expand Down

0 comments on commit cd13adc

Please sign in to comment.