private static SDataParameters GetPostParameters <T>(ISDataClient client, T content, string path, SDataPayloadOptions options) { Guard.ArgumentNotNull(client, "client"); Guard.ArgumentNotNull(content, "content"); Guard.ArgumentNotNullOrEmptyString(path, "path"); if (options == null) { options = new SDataPayloadOptions(); } var resource = ContentHelper.Serialize(content, client.NamingScheme) as SDataResource; if (resource == null) { throw new SDataClientException("Only resources can be posted"); } resource.HttpMethod = HttpMethod.Post; return(new SDataParameters { Method = HttpMethod.Post, Path = path, Content = resource, Include = options.Include, Select = options.Select, Precedence = options.Precedence }); }
private static SDataParameters GetGetParameters(ISDataClient client, string key, string etag, string path, SDataPayloadOptions options) { Guard.ArgumentNotNull(client, "client"); Guard.ArgumentNotNullOrEmptyString(key, "key"); Guard.ArgumentNotNullOrEmptyString(path, "path"); if (options == null) { options = new SDataPayloadOptions(); } return(new SDataParameters { Path = string.Format("{0}({1})", path, SDataUri.FormatConstant(key)), ETag = etag, Include = options.Include, Select = options.Select, Precedence = options.Precedence }); }
private static SDataParameters GetPutParameters <T>(ISDataClient client, T content, string path, SDataPayloadOptions options) { Guard.ArgumentNotNull(client, "client"); Guard.ArgumentNotNull(content, "content"); Guard.ArgumentNotNullOrEmptyString(path, "path"); if (options == null) { options = new SDataPayloadOptions(); } return(new SDataParameters { Method = HttpMethod.Put, Path = string.Format("{0}({1})", path, SDataUri.FormatConstant(GetKey(content))), Content = content, ETag = GetETag(content), Include = options.Include, Select = options.Select, Precedence = options.Precedence }); }
public SDataBatch(ISDataClient client, string path, SDataPayloadOptions options) { _client = client; _path = path; _options = options ?? new SDataPayloadOptions(); }
public static ISDataBatch <T> CreateBatch <T>(this ISDataClient client, string path = null, SDataPayloadOptions options = null) { Guard.ArgumentNotNull(client, "client"); return(new SDataBatch <T>(client, GetPath <T>(path), options)); }
public static ISDataBatch <SDataResource> CreateBatch(this ISDataClient client, string path, SDataPayloadOptions options = null) { return(CreateBatch <SDataResource>(client, path, options)); }
public static Task <T> PutAsync <T>(this ISDataClient client, T content, string path = null, SDataPayloadOptions options = null, CancellationToken cancel = default(CancellationToken)) { return(client.ExecuteAsync <T>(GetPutParameters(client, content, GetPath <T>(path), options), cancel) .ContinueWith(task => task.Result.Content, cancel)); }
public static T Put <T>(this ISDataClient client, T content, string path = null, SDataPayloadOptions options = null) { return(client.Execute <T>(GetPutParameters(client, content, GetPath <T>(path), options)).Content); }
public static Task <T> GetAsync <T>(this ISDataClient client, T content, string path = null, SDataPayloadOptions options = null, CancellationToken cancel = default(CancellationToken)) { Guard.ArgumentNotNull(content, "content"); return(client.ExecuteAsync <T>(GetGetParameters(client, GetKey(content), GetETag(content), GetPath <T>(path), options), cancel) .ContinueWith(task => !Equals(task.Result.Content, default(T)) ? task.Result.Content : content, cancel)); }
public static Task <T> GetAsync <T>(this ISDataClient client, string key, string path, T prototype, SDataPayloadOptions options = null, CancellationToken cancel = default(CancellationToken)) { return(GetAsync <T>(client, key, path, options, cancel)); }
public static Task <SDataResource> GetAsync(this ISDataClient client, string key, string path = null, SDataPayloadOptions options = null, CancellationToken cancel = default(CancellationToken)) { return(GetAsync <SDataResource>(client, key, path, options, cancel)); }
public static T Get <T>(this ISDataClient client, T content, string path = null, SDataPayloadOptions options = null) { Guard.ArgumentNotNull(content, "content"); var results = client.Execute <T>(GetGetParameters(client, GetKey(content), GetETag(content), GetPath <T>(path), options)); return(!Equals(results.Content, default(T)) ? results.Content : content); }
public static T Get <T>(this ISDataClient client, string key, string path, T prototype, SDataPayloadOptions options = null) { return(Get <T>(client, key, path, options)); }
public static SDataResource Get(this ISDataClient client, string key, string path, SDataPayloadOptions options = null) { return(Get <SDataResource>(client, key, path, options)); }