protected override Stream LoadFile() { if (string.IsNullOrEmpty(_document.Key)) { return(Stream.Null); } if (_formMode) { var results = _client.Execute <byte[]>(new SDataParameters { Path = "libraryDocuments(" + SDataUri.FormatConstant(_document.Key) + ")/file" }); return(results.Content != null ? new MemoryStream(results.Content) : Stream.Null); } else { var results = _client.Execute(new SDataParameters { Path = "libraryDocuments(" + SDataUri.FormatConstant(_document.Key) + ")", Precedence = 0, ExtensionArgs = { { "includeFile", "true" } } }); return(results.Files.Count == 1 ? results.Files[0].Stream : Stream.Null); } }
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 IEnumerable <T> Enumerate <T>(this ISDataClient client, string path = null, SDataEnumerateOptions options = null) { var parms = GetEnumerateParameters(client, GetPath <T>(path), options); while (true) { var collection = client.Execute <SDataCollection <T> >(parms).Content; if (collection.Count == 0) { break; } foreach (var item in collection) { yield return(item); } parms.StartIndex = (parms.StartIndex ?? 1) + collection.Count; if (collection.TotalResults != null && parms.StartIndex > collection.TotalResults) { break; } } }
public static T CallService <T>(this ISDataClient client, Expression <Func <T> > methodCall, string path = null) { var content = client.Execute <SDataResource>(GetServiceParameters(client, methodCall.Body, path)).Content; return(GetServiceResult <T>(client, methodCall.Body, content)); }
public static void CallService(this ISDataClient client, Expression <Action> methodCall, string path = null) { client.Execute(GetServiceParameters(client, methodCall.Body, path)); }
public static void Delete <T>(this ISDataClient client, T content, string path = null) { client.Execute(GetDeleteParameters(client, content, GetPath <T>(path))); }
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); }