From 34c45162440a0080eb9b402ffc531a74d4ad6d10 Mon Sep 17 00:00:00 2001 From: alexander Date: Tue, 9 Jul 2024 11:11:47 +0300 Subject: [PATCH] Update SessionData.cs - Added "ExperationTime" property --- source/TuviAuthProtonLib/SessionData.cs | 29 +++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/source/TuviAuthProtonLib/SessionData.cs b/source/TuviAuthProtonLib/SessionData.cs index 81abb62..b2cd211 100644 --- a/source/TuviAuthProtonLib/SessionData.cs +++ b/source/TuviAuthProtonLib/SessionData.cs @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright 2023 Eppie(https://eppie.io) +// Copyright 2024 Eppie(https://eppie.io) // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////////////////// using System; +using System.Collections.Generic; namespace Tuvi.Auth.Proton { @@ -25,25 +26,29 @@ public struct SessionData : IEquatable public string Uid { get; set; } public string AccessToken { get; set; } public string TokenType { get; set; } + public long ExpirationTime { get; set; } - public bool Equals(SessionData other) + public override bool Equals(object obj) { - return string.Equals(Uid, other.Uid, StringComparison.Ordinal) && - string.Equals(TokenType, other.TokenType, StringComparison.Ordinal) && - string.Equals(AccessToken, other.AccessToken, StringComparison.Ordinal); + return obj is SessionData data && Equals(data); } - public override bool Equals(object obj) + public override int GetHashCode() { - if (obj is SessionData sessionData) - return Equals(sessionData); - - return false; + int hashCode = 1002824224; + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Uid); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(AccessToken); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(TokenType); + hashCode = hashCode * -1521134295 + ExpirationTime.GetHashCode(); + return hashCode; } - public override int GetHashCode() + public bool Equals(SessionData other) { - return (Uid, TokenType, AccessToken).GetHashCode(); + return Uid == other.Uid && + AccessToken == other.AccessToken && + TokenType == other.TokenType && + ExpirationTime == other.ExpirationTime; } public static bool operator ==(SessionData left, SessionData right)