using System; using System.Text.Json.Serialization; using Socialvoid.Errors; using System.Text.Json; namespace Socialvoid.JObjects { /// /// A with a specified result type. /// since: v0.0.0 /// [Serializable] public sealed class JResponse where T: class { //------------------------------------------------- #region Constant's Region // some members here #endregion //------------------------------------------------- #region static Properties Region // some members here #endregion //------------------------------------------------- #region Properties Region /// /// The Json-rpc version. /// since: v0.0.0 /// [JsonPropertyName("jsonrpc")] public string RPCVersion { get; set; } /// /// The Json-rpc request id. /// since: v0.0.0 /// [JsonPropertyName("id")] public long ID { get; set; } /// /// The results. /// since: v0.0.0 /// [JsonPropertyName("result")] public T Result { get; set; } /// /// The results. /// since: v0.0.0 /// [JsonPropertyName("error")] public JError Error { 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 #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 /// /// Checks if the current response has error or not. /// since: v0.0.0 /// public bool HasError() { return Error != null; } /// /// Will convert the current property of this value /// to a . /// since: v0.0.0 /// /// /// returns a if and only if the /// property is not null; otherwise returns null. /// public GeneralException GetException() { if (!HasError()) { return null; } return GeneralException.GetException(Error.Message, (ErrorCodes)Error.Code); } #endregion //------------------------------------------------- #region Set Method's Region // some methods here #endregion //------------------------------------------------- #region static Method's Region /// /// Will convert a json string to a . /// since: v0.0.0 /// /// /// returns a value. /// public static JResponse Deserialize(string text) { return JsonSerializer.Deserialize>(text); } #endregion //------------------------------------------------- } }