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); uri.AppendPath(ServiceTerm); if (!string.IsNullOrEmpty(OperationName)) { uri.AppendPath(OperationName); } }
protected override void BuildUrl(SDataUri uri) { base.BuildUrl(uri); if (!string.IsNullOrEmpty(ResourceKind)) { uri.AppendPath(ResourceKind); } uri.AppendPath(ServiceTerm); }
private void UpdateUrl() { var uri = new SDataUri(Client.Uri); if (!string.IsNullOrEmpty(tbTemplateResourceKind.Text)) { uri.AppendPath(tbTemplateResourceKind.Text); } uri.AppendPath("$template"); tbTemplateURL.Text = uri.ToString(); }
/// <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); }
private void btnInitialize_Click(object sender, EventArgs e) { var server = tbServer.Text; var pos = server.IndexOf(':'); int port; if (pos >= 0 && int.TryParse(server.Substring(pos + 1), out port)) { server = server.Substring(0, pos); } else { port = 80; } var uri = new SDataUri { Scheme = cbProtocol.Text, Host = server, Port = port }; uri.AppendPath(tbVirtualDirectory.Text, tbApplication.Text, tbContract.Text, tbDataSet.Text); Client.Uri = uri.ToString(); Client.UserName = tbUserName.Text; Client.Password = tbPassword.Text; StatusLabel.Text = "SData client initialized."; }
protected override void BuildUrl(SDataUri uri) { base.BuildUrl(uri); foreach (var value in ResourceProperties) { uri.AppendPath(value); } }
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.GetPathSegment(4).Text); Assert.AreEqual("name", uri.GetPathSegment(6).Text); Assert.AreEqual("sdata/-/-/-/resource/$service/name/test", uri.DirectPath); Assert.AreEqual("http://test.com/sdata/-/-/-/resource/$service/name/test", uri.ToString()); }
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()); }
private void UpdateUrl() { var uri = new SDataUri(Client.Uri); if (!string.IsNullOrEmpty(tbRPResourceKind.Text)) { var selector = tbRPResourceSelector.Text; if (!string.IsNullOrEmpty(selector)) { selector = SDataUri.FormatConstant(selector); } uri.AppendPath(new UriPathSegment(tbRPResourceKind.Text, selector)); } if (lbProperties.Items.Count > 0) { uri.AppendPath(lbProperties.Items.Cast <string>().ToArray()); } tbResourcePropertiesURL.Text = uri.ToString(); }
private void UpdateUrl() { var uri = new SDataUri(Client.Uri) { StartIndex = (int)numStartIndex.Value, Count = (int)numCount.Value }; if (!string.IsNullOrEmpty(tbCollectionResourceKind.Text)) { uri.AppendPath(tbCollectionResourceKind.Text); } tbCollectionURL.Text = uri.ToString(); }
private void UpdateUrl() { var uri = new SDataUri(Client.Uri); if (!string.IsNullOrEmpty(tbSingleResourceKind.Text)) { var selector = tbSingleResourceSelector.Text; if (!string.IsNullOrEmpty(selector)) { selector = SDataUri.FormatConstant(selector); } uri.AppendPath(new UriPathSegment(tbSingleResourceKind.Text, selector)); } if (!string.IsNullOrEmpty(tbSingleResourceInclude.Text)) { uri.Include = tbSingleResourceInclude.Text; } tbSingleURL.Text = uri.ToString(); }
private void FormatUrl() { var server = tbServer.Text; var pos = server.IndexOf(':'); var uri = new SDataUri(); int port; if (pos >= 0 && int.TryParse(server.Substring(pos + 1), out port)) { server = server.Substring(0, pos); uri.Port = port; } uri.Scheme = cbProtocol.Text; uri.Host = server; uri.AppendPath(tbVirtualDirectory.Text, tbApplication.Text, tbContract.Text, tbDataSet.Text); tbURL.Text = uri.ToString(); }
protected override void BuildUrl(SDataUri uri) { base.BuildUrl(uri); uri.AppendPath(SchemaTerm); }
private SDataRequest CreateBatchRequest(ICollection <SDataParameters> items) { Guard.ArgumentNotNull(items, "items"); var resources = new SDataCollection <SDataResource>(items.Count); string path = null; MediaType?contentType = null; var include = new List <string>(); var select = new List <string>(); int? precedence = null; MediaType?format = null; string language = null; string version = null; var accept = new List <MediaType>(); var form = new Dictionary <string, string>(); var files = new List <AttachedFile>(); var extensionArgs = new Dictionary <string, string>(); foreach (var parms in items) { if (parms.StartIndex != null) { throw new NotSupportedException("StartIndex not supported in batch requests"); } if (parms.Count != null) { throw new NotSupportedException("Count not supported in batch requests"); } if (parms.Where != null) { throw new NotSupportedException("Where not supported in batch requests"); } if (parms.OrderBy != null) { throw new NotSupportedException("OrderBy not supported in batch requests"); } if (parms.Search != null) { throw new NotSupportedException("Search not supported in batch requests"); } if (parms.TrackingId != null) { throw new NotSupportedException("TrackingId not supported in batch requests"); } if (parms.IncludeSchema != null) { throw new NotSupportedException("IncludeSchema not supported in batch requests"); } if (parms.ReturnDelta != null) { throw new NotSupportedException("ReturnDelta not supported in batch requests"); } if (parms.Path != path) { if (path != null) { throw new SDataClientException("All non-null path values must be the same"); } path = parms.Path; } if (parms.ContentType != contentType) { if (contentType != null) { throw new SDataClientException("All non-null content type values must be the same"); } contentType = parms.ContentType; } if (parms.Include != null) { include.AddRange(parms.Include.Split(',')); } if (parms.Select != null) { select.AddRange(parms.Select.Split(',')); } if (parms.Precedence != null && parms.Precedence != precedence) { precedence = Math.Max(precedence ?? 0, parms.Precedence.Value); } if (parms.Format != format) { if (format != null) { throw new SDataClientException("All non-null format values must be the same"); } format = parms.Format; } if (parms.Language != language) { if (language != null) { throw new SDataClientException("All non-null language values must be the same"); } language = parms.Language; } if (parms.Version != version) { if (version != null) { throw new SDataClientException("All non-null version values must be the same"); } version = parms.Version; } if (parms.Accept != null) { accept.AddRange(parms.Accept); } foreach (var data in parms.Form) { form.Add(data.Key, data.Value); } files.AddRange(parms.Files); foreach (var arg in parms.ExtensionArgs) { extensionArgs[arg.Key] = arg.Value; } SDataResource resource; if (parms.Content == null) { resource = new SDataResource(); } else { var content = parms.Content; if (parms.Method == HttpMethod.Put && DifferentialUpdate) { var tracking = content as IChangeTracking; if (tracking != null) { content = tracking.GetChanges(); if (content == null) { throw new SDataClientException("Content doesn't have any changes"); } } } resource = ContentHelper.Serialize(content, NamingScheme) as SDataResource; if (resource == null) { throw new SDataClientException("Only resources can be submitted in batch requests"); } } resource.HttpMethod = parms.Method; if (parms.Method != HttpMethod.Post) { if (resource.Key == null) { throw new SDataClientException("A selector must be specified for GET, PUT and DELETE batch requests"); } var itemUri = new SDataUri(Uri) { Include = parms.Include, Select = parms.Select, Precedence = parms.Precedence }; if (path != null) { itemUri.AppendPath(path); } itemUri.LastPathSegment.Selector = SDataUri.FormatConstant(resource.Key); resource.Id = itemUri.AbsoluteUri; resource.Url = itemUri.Uri; } if (parms.ETag != null) { resource.IfMatch = parms.ETag; } resources.Add(resource); } var uri = new SDataUri(Uri) { Precedence = precedence, Format = format ?? Format, Language = language ?? Language, Version = version ?? Version }; if (path != null) { uri.AppendPath(path); } uri.AppendPath("$batch"); if (include.Count > 0) { uri.Include = string.Join(",", include.Distinct().ToArray()); } if (select.Count > 0) { uri.Select = string.Join(",", select.Distinct().ToArray()); } foreach (var arg in extensionArgs) { uri["_" + arg.Key] = arg.Value; } var request = CreateRequest(uri, HttpMethod.Post, resources); request.ContentType = contentType ?? Format; if (accept.Count > 0) { request.Accept = accept.Distinct().ToArray(); } foreach (var data in form) { request.Form.Add(data.Key, data.Value); } foreach (var file in files) { request.Files.Add(file); } if (language != null) { request.AcceptLanguage = language ?? Language; } TraceRequest(request); return(request); }
private SDataRequest CreateRequest(SDataParameters parms, bool responseContentIgnored) { Guard.ArgumentNotNull(parms, "parms"); var uri = new SDataUri(Uri) { StartIndex = parms.StartIndex, Count = parms.Count, Where = parms.Where, OrderBy = parms.OrderBy, Search = parms.Search, Include = parms.Include, Select = parms.Select, Precedence = parms.Precedence, IncludeSchema = parms.IncludeSchema, ReturnDelta = parms.ReturnDelta, TrackingId = parms.TrackingId, Format = parms.Format, Language = parms.Language, Version = parms.Version }; if (parms.Method != HttpMethod.Delete) { if (uri.Precedence == null && responseContentIgnored) { uri.Precedence = 0; } if (uri.Format == null) { uri.Format = Format; } if (uri.Language == null) { uri.Language = Language; } if (uri.Version == null) { uri.Version = Version; } } if (parms.Path != null) { uri.AppendPath(parms.Path); } foreach (var arg in parms.ExtensionArgs) { uri["_" + arg.Key] = arg.Value; } var content = parms.Content; if (parms.Method == HttpMethod.Put && DifferentialUpdate) { var tracking = content as IChangeTracking; if (tracking != null) { content = tracking.GetChanges(); if (content == null) { throw new SDataClientException("Content doesn't have any changes"); } } } var request = CreateRequest(uri, parms.Method, content); request.ContentType = parms.ContentType ?? Format; request.ETag = parms.ETag; foreach (var item in parms.Form) { request.Form.Add(item.Key, item.Value); } foreach (var file in parms.Files) { request.Files.Add(file); } request.Accept = parms.Accept; request.AcceptLanguage = parms.Language ?? Language; TraceRequest(request); return(request); }
protected override void BuildUrl(SDataUri uri) { base.BuildUrl(uri); uri.AppendPath(TemplateTerm); }