示例#1
0
 public static object Get(this IPomonaClient client, string uri, Type type)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     return(client.Get(uri, type, null));
 }
示例#2
0
 public static T Get <T>(this IPomonaClient client, string uri)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     return((T)client.Get(uri, typeof(T), null));
 }
示例#3
0
        public static T Get <T>(this IPomonaClient client, string uri, RequestOptions requestOptions)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            var type     = typeof(T);
            var resource = client.Get(uri, type, requestOptions);

            if (resource == null && type.IsValueType && !type.IsNullable())
            {
                throw new InvalidCastException($"The response from {uri} was null, which can't be cast to {type}.");
            }

            return((T)resource);
        }
示例#4
0
 public TResource Get(TId id)
 {
     return(Client.Get <TResource>(GetResourceUri(id)));
 }