protected override void BuildUrl(SDataUri uri)
 {
     base.BuildUrl(uri);
     uri.AppendPath("$system");
     uri.AppendPath("registry");
     uri.AppendPath("endpoints");
 }
        protected override void BuildUrl(SDataUri uri)
        {
            base.BuildUrl(uri);

            if (!string.IsNullOrEmpty(ResourceKind))
            {
                uri.AppendPath(ResourceKind);
            }

            uri.AppendPath(ServiceTerm);
        }
        /// <summary>
        /// Adds a url to the batch for processing
        /// </summary>
        /// <param name="item">url for batch item</param>
        /// <returns>True if an appropriate pending batch operation was found</returns>
        public bool AddToBatch(SDataBatchRequestItem item)
        {
            Guard.ArgumentNotNull(item, "item");

            var uri = new SDataUri(item.Url)
                      {
                          CollectionPredicate = null,
                          Query = null
                      };

            if (uri.PathSegments.Length > 4)
            {
                uri.TrimRange(4, uri.PathSegments.Length - 4);
            }

            uri.AppendPath("$batch");
            var baseUri = uri.ToString();
            var request = _requests.LastOrDefault(x => string.Equals(x.ToString(), baseUri, StringComparison.InvariantCultureIgnoreCase));

            if (request != null)
            {
                request.Items.Add(item);
                return true;
            }

            return false;
        }
 public void Appending_Segments_To_Specific_Service_Urls_Test()
 {
     var uri = new SDataUri("http://test.com/sdata/-/-/-/resource/$service/name");
     uri.AppendPath("test");
     Assert.AreEqual("resource", uri.CollectionType);
     Assert.AreEqual("name", uri.ServiceMethod);
     Assert.AreEqual("-/-/-/resource/$service/name/test", uri.DirectPath);
     Assert.AreEqual("http://test.com/sdata/-/-/-/resource/$service/name/test", uri.ToString());
 }
 protected override void BuildUrl(SDataUri uri)
 {
     base.BuildUrl(uri);
     uri.AppendPath(SchemaTerm);
 }
 protected override void BuildUrl(SDataUri uri)
 {
     base.BuildUrl(uri);
     uri.AppendPath(TemplateTerm);
 }
        protected override void BuildUrl(SDataUri uri)
        {
            base.BuildUrl(uri);
            uri.AppendPath(ServiceTerm);

            if (!string.IsNullOrEmpty(OperationName))
            {
                uri.AppendPath(OperationName);
            }
        }
        protected override void BuildUrl(SDataUri uri)
        {
            base.BuildUrl(uri);

            foreach (var value in ResourceProperties)
            {
                uri.AppendPath(value);
            }
        }
        private RequestOperation CreateBatchOperation()
        {
            var uri = new SDataUri(Uri);

            if (uri.PathSegments.Length != 4)
            {
                throw new InvalidOperationException("Batch requests can only be made on collection end points");
            }

            var feed = new AtomFeed();

            foreach (var op in _operations)
            {
                AtomEntry entry;

                if (op.Resource == null)
                {
                    if (op.Method != HttpMethod.Post)
                    {
                        throw new InvalidOperationException("A predicate must be specified for GET, PUT and DELETE batch requests");
                    }

                    var entryUri = new SDataUri(uri) {CollectionPredicate = op.Predicate};
                    entry = new AtomEntry {Id = new AtomId(entryUri.Uri)};
                }
                else
                {
                    entry = op.Resource as AtomEntry;

                    if (entry == null)
                    {
                        throw new InvalidOperationException("Only atom entry resources can be submitted in batch requests");
                    }
                }

                entry.SetSDataHttpMethod(op.Method);

                if (!string.IsNullOrEmpty(op.ETag))
                {
                    entry.SetSDataHttpIfMatch(op.ETag);
                }

                feed.AddEntry(entry);
            }

            uri.AppendPath("$batch");
            return new RequestOperation(HttpMethod.Post, feed);
        }