using System.Text.Json.Serialization; namespace Socialvoid.Security { /// /// A object contains basic information /// about the session that the server has created for us. /// since: v0.0.0 /// public sealed class SessionEstablished { //------------------------------------------------- #region Constant's Region // some members here #endregion //------------------------------------------------- #region static Properties Region // some members here #endregion //------------------------------------------------- #region Properties Region /// /// The ID of the session obtained when establishing a session. /// since: v0.0.0 /// [JsonPropertyName("id")] public string SessionID { get; set; } /// /// The Public Hash of the client used when establishing the session. /// since: v0.0.0 /// [JsonPropertyName("challenge")] public string ChallengeSecret { get; set; } #endregion //------------------------------------------------- #region static field's Region // some members here #endregion //------------------------------------------------- #region field's Region // some members here #endregion //------------------------------------------------- #region static event field's Region // some members here #endregion //------------------------------------------------- #region event field's Region // some members here #endregion //------------------------------------------------- #region Constructor's Region /// /// /// public SessionEstablished() { ;// make is private, so user use `EstablishNew` static method. } #endregion //------------------------------------------------- #region Destructor's Region // some members here #endregion //------------------------------------------------- #region Initialize Method's Region // some methods here #endregion //------------------------------------------------- #region Graphical Method's Region // some methods here #endregion //------------------------------------------------- #region event Method's Region // some methods here #endregion //------------------------------------------------- #region overrided Method's Region // some methods here #endregion //------------------------------------------------- #region ordinary Method's Region // some methods here #endregion //------------------------------------------------- #region Get Method's Region /// /// This method will return the challenge secret received from the /// server. /// since: v0.0.0 /// /// /// null if this object doesn't have any challenge secret; /// otherwise a valid challenge secret. /// public string GetChallengeSecret() { return string.IsNullOrWhiteSpace(ChallengeSecret) ? null : ChallengeSecret; } #endregion //------------------------------------------------- #region Set Method's Region // some methods here #endregion //------------------------------------------------- #region static Method's Region /// /// Establishes a new session. /// since: v0.0.0 /// /// /// the session id returned from the server or being stored in /// a file. /// /// /// The challenge secret returned from the server. /// it can be null. /// please do notice that when you are going to load an already /// existing session from a file, this parameter should remain null. /// /// /// A new instance of class. /// public static SessionEstablished EstablishNew(string id, string challenge = null) { return new() { SessionID = id, ChallengeSecret = challenge, }; } #endregion //------------------------------------------------- } }