protected LazyListProxy(string uri, IPomonaClient clientBase) { if (uri == null) throw new ArgumentNullException("uri"); this.uri = uri; this.clientBase = clientBase; }
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)); }
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)); }
internal ClientSerializationContextProvider(ClientTypeMapper clientTypeMapper, IPomonaClient client) { if (clientTypeMapper == null) throw new ArgumentNullException("clientTypeMapper"); if (client == null) throw new ArgumentNullException("client"); this.clientTypeMapper = clientTypeMapper; this.client = client; }
internal RestQueryProvider(IPomonaClient client) { if (client == null) { throw new ArgumentNullException(nameof(client)); } Client = client; }
public ClientRepository(IPomonaClient client, string uri, IEnumerable results, IClientResource parent) { if (client == null) { throw new ArgumentNullException(nameof(client)); } Client = client; Uri = uri; this.results = results as IEnumerable <TResource> ?? (results != null ? results.Cast <TResource>() : null); }
internal static Task <object> PostAsync <T>(this IPomonaClient client, string uri, Action <T> postAction, RequestOptions options) { if (client == null) { throw new ArgumentNullException(nameof(client)); } var postForm = client.TypeMapper.CreatePostForm(typeof(T)); postAction((T)postForm); return(client.PostAsync(uri, postForm, options)); }
internal static object CreateForType(Type collectionType, string uri, IPomonaClient clientBase) { Type[] genArgs; if (collectionType.TryExtractTypeArguments(typeof(ISet<>), out genArgs)) return Activator.CreateInstance(typeof(LazySetProxy<>).MakeGenericType(genArgs), uri, clientBase); if (collectionType.TryExtractTypeArguments(typeof(IEnumerable<>), out genArgs)) return Activator.CreateInstance(typeof(LazyListProxy<>).MakeGenericType(genArgs), uri, clientBase); throw new NotSupportedException("Unable to create lazy list proxy for collection type " + collectionType); }
public static T GetLazy <T>(this IPomonaClient client, string uri) { if (client == null) { throw new ArgumentNullException(nameof(client)); } var typeInfo = client.GetResourceInfoForType(typeof(T)); var proxy = (LazyProxyBase)Activator.CreateInstance(typeInfo.LazyProxyType); proxy.Initialize(uri, client, typeInfo.PocoType); return((T)((object)proxy)); }
internal ClientSerializationContextProvider(ClientTypeMapper clientTypeMapper, IPomonaClient client, IResourceLoader resourceLoader) { if (clientTypeMapper == null) throw new ArgumentNullException(nameof(clientTypeMapper)); if (client == null) throw new ArgumentNullException(nameof(client)); if (resourceLoader == null) throw new ArgumentNullException(nameof(resourceLoader)); this.clientTypeMapper = clientTypeMapper; this.client = client; this.resourceLoader = resourceLoader; }
internal static object CreateForType(Type collectionType, string uri, IPomonaClient clientBase) { Type[] genArgs; if (collectionType.TryExtractTypeArguments(typeof(ISet <>), out genArgs)) { return(Activator.CreateInstance(typeof(LazySetProxy <>).MakeGenericType(genArgs), uri, clientBase)); } if (collectionType.TryExtractTypeArguments(typeof(IEnumerable <>), out genArgs)) { return(Activator.CreateInstance(typeof(LazyListProxy <>).MakeGenericType(genArgs), uri, clientBase)); } throw new NotSupportedException("Unable to create lazy list proxy for collection type " + collectionType); }
public static async Task <T> GetAsync <T>(this IPomonaClient client, string uri, RequestOptions requestOptions) { if (client == null) { throw new ArgumentNullException(nameof(client)); } var type = typeof(T); var resource = await client.GetAsync(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); }
public ClientDeserializationContext(ITypeResolver typeMapper, IPomonaClient client, IResourceLoader resourceLoader) { if (typeMapper == null) { throw new ArgumentNullException(nameof(typeMapper)); } if (resourceLoader == null) { throw new ArgumentNullException(nameof(resourceLoader)); } this.typeMapper = typeMapper; this.client = client; this.resourceLoader = resourceLoader; }
internal static async Task <T> PatchAsync <T>(this IPomonaClient client, T target, Action <T> updateAction, Action <IRequestOptions <T> > options = null) { if (client == null) { throw new ArgumentNullException(nameof(client)); } var patchForm = (T)client.TypeMapper.CreatePatchForm(typeof(T), target); updateAction(patchForm); var requestOptions = new RequestOptions <T>(); options?.Invoke(requestOptions); return((T)await client.PatchAsync(patchForm, requestOptions)); }
public static T Patch <T>(this IPomonaClient client, T target, Action <T> updateAction, Action <IRequestOptions <T> > options = null) { if (client == null) { throw new ArgumentNullException(nameof(client)); } var patchForm = (T)client.TypeMapper.CreatePatchForm(typeof(T), target); updateAction(patchForm); var requestOptions = new RequestOptions <T>(); if (options != null) { options(requestOptions); } return((T)client.Patch(patchForm, requestOptions)); }
internal ClientSerializationContextProvider(ClientTypeMapper clientTypeMapper, IPomonaClient client, IResourceLoader resourceLoader) { if (clientTypeMapper == null) { throw new ArgumentNullException(nameof(clientTypeMapper)); } if (client == null) { throw new ArgumentNullException(nameof(client)); } if (resourceLoader == null) { throw new ArgumentNullException(nameof(resourceLoader)); } this.clientTypeMapper = clientTypeMapper; this.client = client; this.resourceLoader = resourceLoader; }
public ChildResourceRepository(IPomonaClient client, string uri, IEnumerable results, IClientResource parent) : base(client, uri, results, parent) { this.parent = parent; }
protected RootResource(string baseUri, IRequestDispatcher dispatcher) { BaseUri = baseUri; this.client = new PomonaClient(ClientTypeMapper, dispatcher); InstantiateClientRepositories(); }
protected RootResource(string baseUri, IWebClient webClient) { BaseUri = baseUri; this.client = new PomonaClient(ClientTypeMapper, webClient); InstantiateClientRepositories(); }
internal static object CreateForType(Type elementType, string uri, IPomonaClient clientBase) { return Activator.CreateInstance(typeof(LazyListProxy<>).MakeGenericType(elementType), uri, clientBase); }
public LazyListProxy(string uri, IPomonaClient clientBase) : base(uri, clientBase) { }