Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
                }
            }
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 public static void CallService(this ISDataClient client, Expression <Action> methodCall, string path = null)
 {
     client.Execute(GetServiceParameters(client, methodCall.Body, path));
 }
Exemplo n.º 6
0
 public static void Delete <T>(this ISDataClient client, T content, string path = null)
 {
     client.Execute(GetDeleteParameters(client, content, GetPath <T>(path)));
 }
Exemplo n.º 7
0
 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);
 }