You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
|
- using System;
- using System.Text;
- using Newtonsoft.Json;
- namespace Leadercraft.Server
- {
- internal class LeadercraftResult<T>
- {
- private string _responseJson;
-
- public readonly int StatusCode;
-
- public bool IsError { get => StatusCode < 200 || StatusCode > 299; }
-
- public ResultStruct<T> ParseResult()
- {
- return JsonConvert.DeserializeObject<ResultStruct<T>>(_responseJson);
- }
-
- public ResultStruct<string> ParseError()
- {
- return JsonConvert.DeserializeObject<ResultStruct<string>>(_responseJson);
- }
-
- public LeadercraftResult(string response, int status = 200)
- {
- this._responseJson = response;
- this.StatusCode = status;
- }
-
- public LeadercraftResult(byte[] response, int status = 200)
- {
- this._responseJson = Encoding.ASCII.GetString(response);
- this.StatusCode = status;
- }
- }
- }
|