Beispiel #1
0
        private T GetResource <T>(string resourceUri) where T : class
        {
            RestAdapter adapter = GetAdapter();

            try
            {
                return(adapter.Get <T>(new Uri(this.apiUriBase + resourceUri)));
            }
            catch (Exception ex)
            {
                throw new ApiException(ex);
            }
            finally
            {
                ReleaseAdapter(adapter);
            }
        }
Beispiel #2
0
        private IList <TItem> GetResourceList <TContainer, TItem>(string resourceUri)
            where TContainer : class, IEnumerable <TItem>
            where TItem : class
        {
            RestAdapter adapter = GetAdapter();

            try
            {
                TContainer items = adapter.Get <TContainer>(new Uri(this.apiUriBase + resourceUri));
                return(new List <TItem>(items));
            }
            catch (Exception ex)
            {
                throw new ApiException(ex);
            }
            finally
            {
                ReleaseAdapter(adapter);
            }
        }
Beispiel #3
0
        private object Get(string resourceUri)
        {
            if (null == resourceUri)
            {
                throw new ArgumentNullException("resourceUri");
            }

            RestAdapter adapter = GetAdapter();

            try
            {
                return(adapter.Get(new Uri(this.apiUriBase + resourceUri)));
            }
            catch (Exception ex)
            {
                throw new ApiException(ex);
            }
            finally
            {
                ReleaseAdapter(adapter);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Gets a resource where the expected type is not know.
        /// </summary>
        /// <param name="resourceUri">The resourceUri</param>
        /// <exception cref="ApiException">The request failed. See inner exception for details.</exception>
        /// <returns>The resource</returns>
        public object Get(Uri resourceUri)
        {
            if (null == resourceUri)
            {
                throw new ArgumentNullException("resourceUri");
            }

            RestAdapter adapter = GetAdapter();

            try
            {
                return(adapter.Get(resourceUri));
            }
            catch (Exception ex)
            {
                throw new ApiException(ex);
            }
            finally
            {
                ReleaseAdapter(adapter);
            }
        }