public NorenResponseMsg GetNorenMessage(string data)
        {
            NorenResponseMsg msg = new NorenResponseMsg();

            try
            {
                msg = JsonConvert.DeserializeObject <NorenResponseMsg>(data);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error deserializing data {ex.ToString()}");
                return(null);
            }
            return(msg);
        }
        public override void OnMessageNotify(HttpResponseMessage httpResponse, string data)
        {
            //T Message = Helpers.ToObject<T>(PayLoad);
            T Message = new T();

            if (Message == null)
            {
                return;
            }

            if (httpResponse.IsSuccessStatusCode)
            {
                try
                {
                    Message = JsonConvert.DeserializeObject <T>(data);
                    ResponseNotifyInstance?.Invoke(Message);
                    ResponseHandler(Message, true);
                }
                catch (JsonReaderException ex)
                {
                    Console.WriteLine($"Error deserializing data {ex.ToString()}");
                    return;
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error deserializing data {ex.ToString()}");
                    return;
                }
            }
            else if (httpResponse.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                NorenResponseMsg msg = GetNorenMessage(data);
                Message.stat = msg.stat;
                Message.emsg = msg.emsg;

                ResponseHandler(Message, false);
            }
            else
            {
                Message.stat = httpResponse.StatusCode.ToString();
                Message.emsg = data;
                ResponseHandler(Message, false);
            }
        }
        public override void OnMessageNotify(HttpResponseMessage httpResponse, string data)
        {
            //T Message = Helpers.ToObject<T>(PayLoad);
            T Message = new T();

            if (Message == null)
            {
                return;
            }

            if (httpResponse.IsSuccessStatusCode)
            {
                try
                {
                    if (data[0] == '[')
                    {
                        //json lists begin with [
                        Message.list = JsonConvert.DeserializeObject <List <U> >(data);
                    }
                    else
                    {
                        //error messages
                        NorenResponseMsg msg = GetNorenMessage(data);
                        Message.Copy(msg);

                        ResponseHandler(Message, false);
                        return;
                    }
                }
                catch (JsonReaderException ex)
                {
                    Console.WriteLine($"Message Received {data}");
                    Console.WriteLine($"Error deserializing data {ex.ToString()}");
                    return;
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error deserializing data {ex.ToString()}");
                    return;
                }
                ResponseNotifyInstance?.Invoke(Message);
                ResponseHandler(Message, true);
            }
            else if (httpResponse.StatusCode == System.Net.HttpStatusCode.BadRequest)
            {
                NorenResponseMsg msg = new NorenResponseMsg();

                try
                {
                    msg = JsonConvert.DeserializeObject <NorenResponseMsg>(data);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error deserializing data {ex.ToString()}");
                    return;
                }
                Message.stat = msg.stat;
                Message.emsg = msg.emsg;

                ResponseHandler(Message, false);
            }
            else
            {
                Message.stat = httpResponse.StatusCode.ToString();
                Message.emsg = data;
                ResponseHandler(Message, false);
            }
        }
 public void Copy(NorenResponseMsg baseObject)
 {
     this.stat = baseObject.stat;
     this.emsg = baseObject.emsg;
     list      = null;
 }
 internal void OnLoginResponseNotify(NorenResponseMsg responseMsg)
 {
     loginResp = responseMsg as LoginResponse;
 }