Exemplo n.º 1
0
        public static RetrofitError httpError(string url, string response, Converter.Converter converter,
                                              Type successType)
        {
            var message = response;

//				string message = response.getStatus() + " " + response.getReason();
            return(new RetrofitError(message, url, response, converter, successType, Kind.HTTP, null));
        }
Exemplo n.º 2
0
 /// <summary>
 /// The converter used for serialization and deserialization of objects.
 /// </summary>
 /// <param name="converter"></param>
 /// <returns></returns>
 public Builder SetConverter(Converter.Converter converter)
 {
     if (converter == null)
     {
         throw new ArgumentException("Converter may not be null.");
     }
     this.converter = converter;
     return(this);
 }
Exemplo n.º 3
0
 public RetrofitError(string message, string url, string response, Converter.Converter converter,
                      Type successType, Kind kind, Exception exception) : base(message, exception)
 {
     this.url         = url;
     this.response    = response;
     this.converter   = converter;
     this.successType = successType;
     this.kind        = kind;
 }
Exemplo n.º 4
0
 public void Awake()
 {
     methodInfoCache.Clear();
     convert     = new DefalutConvert();
     httpImpl    = SetHttpImpl();
     interceptor = SetIntercepter();
     rxSupport   = new RxSupport(convert, httpImpl, interceptor);
     SetRestAPI();
     StartCoroutine(GenMethodCache());
 }
Exemplo n.º 5
0
 public void Init(bool enableLog, string baseUrl, HttpImplement httpImpl, RequestInterceptor requestInterceptor, Converter.Converter converter, ErrorHandler errorHandler)
 {
     methodInfoCache.Clear();
     this.enableDebug  = enableLog;
     this.baseUrl      = baseUrl;
     this.httpImpl     = httpImpl;
     this.interceptor  = requestInterceptor;
     this.convert      = converter;
     this.errorHandler = errorHandler;
     this.rxSupport    = new RxSupport(convert, httpImpl, interceptor);
 }
        private void Convert(string pythonModulePath, string cSharpProjectPath)
        {
            cSharpProjectPath += @"\Program";
            Directory.CreateDirectory(cSharpProjectPath);

            File.WriteAllText(cSharpProjectPath + @"\Program.csproj", Resources.Program);
            File.WriteAllBytes(cSharpProjectPath + @"\Program.sln", Resources.Program1);
            File.WriteAllText(cSharpProjectPath + @"\Program.cs", Resources.Program2);

            Converter.Converter converter = new Converter.Converter(pythonModulePath, cSharpProjectPath + @"\Program.cs");
        }
Exemplo n.º 7
0
 public BlogListManager()
 {
     _converter = new Converter.Converter();
     _converter.Initialize();
     data = new BindingList <FileTitlePair>(_loader.LoadPosts());
     //TODO: lock directory and files
     InitializeComponent();
     BlogListUI.DisplayMember = nameof(FileTitlePair.Title);
     BlogListUI.ValueMember   = nameof(FileTitlePair.FileName);
     BlogListUI.DataSource    = data;
     _tags = _loader.GetTags();
 }
Exemplo n.º 8
0
        public void RxSendRequest <T>(UniRx.IObserver <T> o, Converter.Converter convert, object request)
        {
            HttpClientRequest httpClientRequest = request as HttpClientRequest;

            if (httpClientRequest != null)
            {
                if (EnableDebug)
                {
                    Debug.LogFormat("Send on threadId:{0}", System.Threading.Thread.CurrentThread.ManagedThreadId);
                }
                httpClientRequest.Send();
            }
        }
Exemplo n.º 9
0
        public object RxBuildRequest <T>(UniRx.IObserver <T> o, Converter.Converter convert, RestMethodInfo methodInfo, string url)
        {
            Action <HttpResponseMessage <string> > responseMessage = message =>
            {
                string errorMessage = "";
                if (IsRequestError(message, out errorMessage))
                {
                    o.OnError(new Exception(errorMessage));
                    return;
                }
                string result = GetSuccessResponse(message);
                //                        result = "[]";
                //                        result = "[asd..s]";
                if (EnableDebug)
                {
                    Debug.LogFormat("Raw Response:{0}", result);
                }
                //Parse Json By Type
                if (typeof(T) == typeof(string))
                {
                    var resultData = (T)(object)result;
                    o.OnNext(resultData);
                    o.OnCompleted();
                    return;
                }
                T    data        = default(T);
                bool formatError = false;
                try
                {
                    data = convert.FromBody <T>(result);
                }
                catch (ConversionException e)
                {
                    formatError = true;
                    o.OnError(new Exception(e.Message));
                }
                if (!formatError)
                {
                    o.OnNext(data);
                    o.OnCompleted();
                }
            };
            HttpClientRequest httpClientRequest = new HttpClientRequest(new Uri(url), responseMessage);

            ConfigureRESTfulApi(methodInfo, httpClientRequest);
            return(httpClientRequest);
        }
Exemplo n.º 10
0
 private void EnsureSaneDefaults()
 {
     if (converter == null)
     {
         converter = new DefalutConvert();
     }
     if (httpImpl == null)
     {
         httpImpl = new HttpClientImpl();
     }
     if (errorHandler == null)
     {
         errorHandler = new DefaultErrorHandler();
     }
     if (requestInterceptor == null)
     {
         requestInterceptor = new DefaultRequestInterceptor();
     }
 }
Exemplo n.º 11
0
 public RxSupport(Converter.Converter convert, HttpImplement httpImpl, RequestInterceptor interceptor)
 {
     this.convert     = convert;
     this.rxHttpImpl  = httpImpl as RxHttpImplement;
     this.interceptor = interceptor;
 }
Exemplo n.º 12
0
 public static RetrofitError conversionError(string url, string response, Converter.Converter converter,
                                             Type successType, ConversionException exception)
 {
     return(new RetrofitError(exception.Message, url, response, converter, successType,
                              Kind.CONVERSION, exception));
 }