Esempio n. 1
0
        public RestMethodInfo(MethodBase method)
        {
            methodBase = method;
            MethodInfo methodInfo           = method as MethodInfo;
            Type       returnType           = methodInfo.ReturnType;
            Type       firstParamType       = methodInfo.GetParameters() != null && methodInfo.GetParameters().Length >= 1 ? methodInfo.GetParameters()[0].ParameterType:null;
            bool       hasReturnType        = returnType != typeof(void);
            bool       firstParamIsCallback = firstParamType != null && firstParamType.IsGenericType && firstParamType.GetGenericTypeDefinition() == typeof(Callback <>);

            IsObservable = returnType.IsGenericType && RxSupport.IsObservable(returnType.GetGenericTypeDefinition());
            if (hasReturnType)
            {
                if (IsObservable)
                {
                    responseType = ResponseType.OBSERVABLE;
                }
                else
                {
                    throw new ArgumentException("Retrofit return type must be IObserable<>!");
                }
            }
            else
            {
                if (firstParamIsCallback)
                {
                    responseType = ResponseType.VOID;
                }
                else
                {
                    throw new ArgumentException("Sync Retrofit first parameter type must be Callback<>!");
                }
            }
        }
Esempio n. 2
0
 public void Awake()
 {
     methodInfoCache.Clear();
     convert     = new DefalutConvert();
     httpImpl    = SetHttpImpl();
     interceptor = SetIntercepter();
     rxSupport   = new RxSupport(convert, httpImpl, interceptor);
     SetRestAPI();
     StartCoroutine(GenMethodCache());
 }
 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);
 }