Exemple #1
0
        public static string GetDescription(this Codes value)
        {
            Type   type = value.GetType();
            string name = Enum.GetName(type, value);

            if (name == null)
            {
                return(null);
            }

            FieldInfo field = type.GetField(name);

            if (field == null)
            {
                return(null);
            }

            DescriptionAttribute attr =
                (DescriptionAttribute)Attribute.GetCustomAttribute(field,
                                                                   typeof(DescriptionAttribute));

            return(attr?.Description);
        }
Exemple #2
0
        public async Task <Codes> GetContext(Codes codes)
        {
            var response = await client.ExecuteAsync(new RestRequest(string.Concat(security.CoreAPI, codes.GetType().Name, "/", codes.Code), Method.GET), source.Token);

            try
            {
                if (response != null && response.RawBytes != null && response.RawBytes.Length > 0)
                {
                    Coin += security.GetSettleTheFare(response.RawBytes.Length);
                    SendMessage(Coin);
                }
                return(JsonConvert.DeserializeObject <Codes>(response.Content));
            }
            catch (Exception ex)
            {
                SendMessage(ex.StackTrace);
                SendMessage((int)response.StatusCode);
            }
            return(codes);
        }
 public async Task <int> EmergencyContext <T>(Codes param) => (int)(await client.ExecuteAsync <T>(new RestRequest(string.Concat(security.CoreAPI, param.GetType().Name, "/", param.Code), Method.PUT).AddJsonBody(param, security.ContentType), source.Token)).StatusCode;
Exemple #4
0
        public async Task <int> PutContext <T>(Codes param)
        {
            var response = await client.ExecuteAsync <T>(new RestRequest(string.Concat(security.CoreAPI, param.GetType().Name, "/", param.Code), Method.PUT).AddJsonBody(param, security.ContentType), source.Token);

            try
            {
                if (response != null && response.RawBytes != null && response.RawBytes.Length > 0)
                {
                    Coin += security.GetSettleTheFare(response.RawBytes.Length);
                    SendMessage(Coin);
                }
                return((int)response.StatusCode);
            }
            catch (Exception ex)
            {
                SendMessage(ex.StackTrace);
                SendMessage((int)response.StatusCode);
            }
            return(int.MinValue);
        }