private void GetModelResponse(RESTConnector.Request req, RESTConnector.Response resp)
        {
            TranslationModel model = new TranslationModel();

            if (resp.Success)
            {
                try
                {
                    fsData   data = null;
                    fsResult r    = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data);
                    if (!r.Succeeded)
                    {
                        throw new WatsonException(r.FormattedMessages);
                    }

                    object obj = model;
                    r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
                    if (!r.Succeeded)
                    {
                        throw new WatsonException(r.FormattedMessages);
                    }
                }
                catch (Exception e)
                {
                    Log.Error("Natural Language Classifier", "GetModel Exception: {0}", e.ToString());
                    resp.Success = false;
                }
            }

            if (((GetModelReq)req).Callback != null)
            {
                ((GetModelReq)req).Callback(resp.Success ? model : null);
            }
        }
        private void GetModelResponse(RESTConnector.Request req, RESTConnector.Response resp)
        {
            TranslationModel            result     = new TranslationModel();
            fsData                      data       = null;
            Dictionary <string, object> customData = ((GetModelReq)req).CustomData;

            if (resp.Success)
            {
                try
                {
                    fsResult r = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data);
                    if (!r.Succeeded)
                    {
                        throw new WatsonException(r.FormattedMessages);
                    }

                    object obj = result;
                    r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
                    if (!r.Succeeded)
                    {
                        throw new WatsonException(r.FormattedMessages);
                    }

                    customData.Add("json", data);
                }
                catch (Exception e)
                {
                    Log.Error("LanguageTranslation.GetModelResponse()", "GetModel Exception: {0}", e.ToString());
                    resp.Success = false;
                }
            }

            if (resp.Success)
            {
                if (((GetModelReq)req).SuccessCallback != null)
                {
                    ((GetModelReq)req).SuccessCallback(result, customData);
                }
            }
            else
            {
                if (((GetModelReq)req).FailCallback != null)
                {
                    ((GetModelReq)req).FailCallback(resp.Error, customData);
                }
            }
        }