コード例 #1
0
ファイル: SchemaProvider.cs プロジェクト: larsw/Simple.OData
        private EdmSchema RequestMetadata()
        {
            var requestBuilder = new CommandRequestBuilder(_urlBase);
            var command        = HttpCommand.Get("$metadata");

            requestBuilder.AddCommandToRequest(command);
            using (var response = new CommandRequestRunner().TryRequest(command.Request))
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    return(ODataHelper.GetSchema(response.GetResponseStream()));
                }
            }
            // TODO
            return(null);
        }
コード例 #2
0
        public override HttpRequest CreateRequest(HttpCommand command, bool returnContent = false)
        {
            var request = new CommandRequestBuilder(this.UrlBase, this.Credentials).CreateRequest(command);
            var content = new StringContent(FormatBatchItem(command));
            content.Headers.ContentType = new MediaTypeHeaderValue("application/http");
            content.Headers.Add("Content-Transfer-Encoding", "binary");

            var requestMessage = new HttpRequestMessage(new HttpMethod(request.Method), request.Uri);
            requestMessage.Content = content;
            if (requestMessage.Content != null)
            {
                _content.Add(requestMessage.Content);
            }

            request.EntryData = command.EntryData;
            if (request.EntryData != null)
            {
                request.EntryData.Add("$Batch-ID", _batchId);
                request.EntryData.Add("$Content-ID", _contentId);
            }
            command.ContentId = _contentId;

            return request;
        }
コード例 #3
0
 private string RequestMetadataAsString(string urlBase, ICredentials credentials = null)
 {
     var requestBuilder = new CommandRequestBuilder(urlBase, credentials);
     var command = HttpCommand.Get(ODataCommand.MetadataLiteral);
     requestBuilder.AddCommandToRequest(command);
     using (var response = new CommandRequestRunner(new ODataClientSettings()).ExecuteRequest(command.Request))
     {
         if (response.StatusCode == HttpStatusCode.OK)
         {
             return new ODataFeedReader().GetSchemaAsString(response.GetResponseStream());
         }
     }
     // TODO
     return null;
 }
コード例 #4
0
 private string RequestMetadataAsString(string urlBase)
 {
     var requestBuilder = new CommandRequestBuilder(urlBase);
     var command = HttpCommand.Get("$metadata");
     requestBuilder.AddCommandToRequest(command);
     using (var response = new CommandRequestRunner().TryRequest(command.Request))
     {
         if (response.StatusCode == HttpStatusCode.OK)
         {
             return ODataHelper.GetSchemaAsString(response.GetResponseStream());
         }
     }
     // TODO
     return null;
 }