Du kan inte välja fler än 25 ämnen
Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
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;
- }
- }
- }
|