• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IODataRequestMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IODataRequestMessage的典型用法代码示例。如果您正苦于以下问题:C# IODataRequestMessage类的具体用法?C# IODataRequestMessage怎么用?C# IODataRequestMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IODataRequestMessage类属于命名空间,在下文中一共展示了IODataRequestMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ODataRequestMessage

        /// <summary>
        /// Constructs an internal wrapper around the <paramref name="requestMessage"/>
        /// that isolates the internal implementation of the ODataLib from the interface.
        /// </summary>
        /// <param name="requestMessage">The request message to wrap.</param>
        internal ODataRequestMessage(IODataRequestMessage requestMessage)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(requestMessage != null, "requestMessage != null");

            this.requestMessage = requestMessage;
        }
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:12,代码来源:ODataRequestMessage.cs


示例2: Process

        public override void Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)
        {
            string asyncToken = this.QueryContext.AsyncToken;
            AsyncTask asyncTask = AsyncTask.GetTask(asyncToken);

            if (asyncTask == null)
            {
                // token is invalid or expired. 
                throw Utility.BuildException(HttpStatusCode.NotFound);
            }
            else
            {
                if (!asyncTask.Ready)
                {
                    ResponseWriter.WriteAsyncPendingResponse(responseMessage, asyncToken);
                }
                else
                {
                    responseMessage.SetHeader(ServiceConstants.HttpHeaders.ContentType, "application/http");
                    responseMessage.SetHeader(ServiceConstants.HttpHeaders.ContentTransferEncoding, ServiceConstants.HttpHeaderValues.Binary);
                    using (var messageWriter = this.CreateMessageWriter(responseMessage))
                    {
                        var asyncWriter = messageWriter.CreateODataAsynchronousWriter();
                        var innerResponse = asyncWriter.CreateResponseMessage();
                        asyncTask.Execute(innerResponse);
                    }
                }
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:29,代码来源:StatusMonitorRequestHandler.cs


示例3: ProcessUpdateEntityReference

        private void ProcessUpdateEntityReference(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage, ODataPath odataPath)
        {
            // This is for change the reference in single-valued navigation property
            // PUT ~/Person(0)/Parent/$ref
            // {
            //     "@odata.context": "http://host/service/$metadata#$ref",
            //     "@odata.id": "Orders(10643)"
            // }

            if (this.HttpMethod == HttpMethod.PATCH)
            {
                throw Utility.BuildException(HttpStatusCode.MethodNotAllowed, "PATCH on a reference link is not supported.", null);
            }

            // Get the parent first
            var level = this.QueryContext.QueryPath.Count - 2;
            var parent = this.QueryContext.ResolveQuery(this.DataSource, level);

            var navigationPropertyName = ((NavigationPropertyLinkSegment)odataPath.LastSegment).NavigationProperty.Name;

            using (var messageReader = new ODataMessageReader(requestMessage, this.GetReaderSettings(), this.DataSource.Model))
            {
                var referenceLink = messageReader.ReadEntityReferenceLink();
                var queryContext = new QueryContext(this.ServiceRootUri, referenceLink.Url, this.DataSource.Model);
                var target = queryContext.ResolveQuery(this.DataSource);

                this.DataSource.UpdateProvider.UpdateLink(parent, navigationPropertyName, target);
                this.DataSource.UpdateProvider.SaveChanges();
            }

            ResponseWriter.WriteEmptyResponse(responseMessage);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:32,代码来源:UpdateHandler.cs


示例4: DetectPayloadKind

 internal override IEnumerable<ODataPayloadKind> DetectPayloadKind(IODataRequestMessage requestMessage, ODataPayloadKindDetectionInfo detectionInfo)
 {
     ExceptionUtils.CheckArgumentNotNull<IODataRequestMessage>(requestMessage, "requestMessage");
     ExceptionUtils.CheckArgumentNotNull<ODataPayloadKindDetectionInfo>(detectionInfo, "detectionInfo");
     Stream messageStream = ((ODataMessage) requestMessage).GetStream();
     return this.DetectPayloadKindImplementation(messageStream, false, true, detectionInfo);
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:ODataAtomFormat.cs


示例5: BatchServiceHost

        /// <summary>
        /// Initializes a new dummy host for the batch request.
        /// This host represents a single operation in the batch.
        /// </summary>
        /// <param name="absoluteServiceUri">Absolute Uri to the service.</param>
        /// <param name="operationMessage">The request message representing a batch operation to wrap.</param>
        /// <param name="contentId">Content id for the given operation host.</param>
        /// <param name="writer">ODataBatchWriter instance.</param>
        /// <param name="odataMaxVersion">OData-MaxVersion header on the batch request. If the OData-MaxVersion header is not specified in the current operation, we default to the MaxDSV from the batch level.</param>
        internal BatchServiceHost(Uri absoluteServiceUri, IODataRequestMessage operationMessage, string contentId, ODataBatchWriter writer, Version odataMaxVersion)
            : this(writer)
        {
            Debug.Assert(absoluteServiceUri != null && absoluteServiceUri.IsAbsoluteUri, "absoluteServiceUri != null && absoluteServiceUri.IsAbsoluteUri");
            Debug.Assert(operationMessage != null, "operationMessage != null");
            this.absoluteServiceUri = absoluteServiceUri;
            this.absoluteRequestUri = RequestUriProcessor.GetAbsoluteUriFromReference(operationMessage.Url, absoluteServiceUri);

            this.requestHttpMethod = operationMessage.Method;
            this.contentId = contentId;

            foreach (KeyValuePair<string, string> header in operationMessage.Headers)
            {
                this.requestHeaders.Add(header.Key, header.Value);
            }

            // If the MaxDSV header is not specified in the current operation, we default to the MaxDSV from the batch level.
            if (string.IsNullOrEmpty(this.requestHeaders[XmlConstants.HttpODataMaxVersion]))
            {
                Debug.Assert(odataMaxVersion != null, "odataMaxVersion != null");
                this.requestHeaders[XmlConstants.HttpODataMaxVersion] = odataMaxVersion.ToString();
            }

            this.requestStream = operationMessage.GetStream();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:34,代码来源:BatchServiceHost.cs


示例6: Process

 public override void Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)
 {
     responseMessage.SetStatusCode(HttpStatusCode.OK);
     using (var writer = this.CreateMessageWriter(responseMessage))
     {
         writer.WriteServiceDocument(this.GenerateServiceDocument());
     }
 }
开发者ID:chinadragon0515,项目名称:ODataSamples,代码行数:8,代码来源:ServiceDocumentHandler.cs


示例7: ODataRequestMessage

        /// <summary>
        /// Constructs an internal wrapper around the <paramref name="requestMessage"/>
        /// that isolates the internal implementation of the ODataLib from the interface.
        /// </summary>
        /// <param name="requestMessage">The request message to wrap.</param>
        /// <param name="writing">true if the request message is being written; false when it is read.</param>
        /// <param name="disableMessageStreamDisposal">true if the stream returned should ignore dispose calls.</param>
        /// <param name="maxMessageSize">The maximum size of the message in bytes (or a negative value if no maximum applies).</param>
        internal ODataRequestMessage(IODataRequestMessage requestMessage, bool writing, bool disableMessageStreamDisposal, long maxMessageSize)
            : base(writing, disableMessageStreamDisposal, maxMessageSize)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(requestMessage != null, "requestMessage != null");

            this.requestMessage = requestMessage;
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:16,代码来源:ODataRequestMessage.cs


示例8: ClientPreference

 /// <summary>
 /// Initializes a new instance of the <see cref="ClientPreference"/> class.
 /// </summary>
 /// <param name="requestDescription">The request description.</param>
 /// <param name="verb">The request verb.</param>
 /// <param name="requestMessage">The request message.</param>
 /// <param name="effectiveMaxResponseVersion">The effective max response version for the request, which is the min of MDSV and MPV.</param>
 public ClientPreference(RequestDescription requestDescription, HttpVerbs verb, IODataRequestMessage requestMessage, Version effectiveMaxResponseVersion)
     : this(InterpretClientPreference(requestDescription, verb, requestMessage))
 {
     if (effectiveMaxResponseVersion >= VersionUtil.Version4Dot0)
     {
         this.annotationFilter = requestMessage.PreferHeader().AnnotationFilter;
     }
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:15,代码来源:ClientPreference.cs


示例9: ODataFeedGenerator

 /// <summary>
 /// Create a new feed generator
 /// </summary>
 /// <param name="requestMessage">The OData request message that was received</param>
 /// <param name="responseMessage">The OData response message to be populated by the generator</param>
 /// <param name="entityMap">The map to use to map RDF URIs to OData types and properties</param>
 /// <param name="baseUri">The base URI for the OData feed</param>
 /// <param name="messageWriterSettings">Additional settings to apply to the generated OData output</param>
 public ODataFeedGenerator(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage, SparqlMap entityMap, string baseUri, ODataMessageWriterSettings messageWriterSettings)
 {
     _request = requestMessage;
     _response = responseMessage;
     _map = entityMap;
     _baseUri = baseUri;
     _writerSettings = messageWriterSettings;
 }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:16,代码来源:ODataFeedGenerator.cs


示例10: Process

        public override void Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)
        {
            if (this.TryDispatch(requestMessage, responseMessage))
            {
                return;
            }

            if (this.QueryContext.Target.TypeKind != EdmTypeKind.Collection)
            {
                throw Utility.BuildException(HttpStatusCode.BadRequest, "The new resource can only be created under collection resource.", null);
            }

            if (this.QueryContext.Target.IsReference)
            {
                this.ProcessCreateLink(requestMessage, responseMessage);
                return;
            }

            try
            {
                var targetEntitySet = (IEdmEntitySetBase)this.QueryContext.Target.NavigationSource;

                // TODO: [lianw] Try to remove "targetEntitySet" later.
                var queryResults = this.QueryContext.ResolveQuery(this.DataSource);

                if (!IsAllowInsert(targetEntitySet as IEdmEntitySet))
                {
                    throw new ODataServiceException(HttpStatusCode.BadRequest, "The insert request is not allowed.", null);
                }

                var bodyObject = ProcessPostBody(requestMessage, targetEntitySet, queryResults);

                using (var messageWriter = this.CreateMessageWriter(responseMessage))
                {
                    this.DataSource.UpdateProvider.SaveChanges();

                    // 11.4.2 Create an Entity
                    // Upon successful completion the service MUST respond with either 201 Created, or 204 No Content if the request included a return Prefer header with a value of return=minimal.
                    responseMessage.SetStatusCode(HttpStatusCode.Created);
                    responseMessage.SetHeader(ServiceConstants.HttpHeaders.Location, Utility.BuildLocationUri(this.QueryContext, bodyObject).OriginalString);
                    var currentETag = Utility.GetETagValue(bodyObject);
                    // if the current entity has ETag field
                    if (currentETag != null)
                    {
                        responseMessage.SetHeader(ServiceConstants.HttpHeaders.ETag, currentETag);
                    }

                    ResponseWriter.WriteEntry(messageWriter.CreateODataEntryWriter(targetEntitySet), bodyObject, targetEntitySet, ODataVersion.V4, null);
                }
            }
            catch
            {
                this.DataSource.UpdateProvider.ClearChanges();
                throw;
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:56,代码来源:CreateHandler.cs


示例11: DetectPayloadKind

        /// <summary>
        /// Detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="requestMessage">The request message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
        internal override IEnumerable<ODataPayloadKind> DetectPayloadKind(
            IODataRequestMessage requestMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(requestMessage, "requestMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            return DetectPayloadKindImplementation(detectionInfo.ContentType);
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:16,代码来源:ODataRawValueFormat.cs


示例12: DetectPayloadKind

        /// <summary>
        /// Detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="requestMessage">The request message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
        internal override IEnumerable<ODataPayloadKind> DetectPayloadKind(
            IODataRequestMessage requestMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(requestMessage, "requestMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            Stream messageStream = ((ODataMessage)requestMessage).GetStream();
            return this.DetectPayloadKindImplementation(messageStream, /*readingResponse*/ false, /*synchronous*/ true, detectionInfo);
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:17,代码来源:ODataAtomFormat.cs


示例13: DetectPayloadKind

        /// <summary>
        /// Detects the payload kinds supported by this format for the specified message payload.
        /// </summary>
        /// <param name="requestMessage">The request message with the payload stream.</param>
        /// <param name="detectionInfo">Additional information available for the payload kind detection.</param>
        /// <returns>The set of <see cref="ODataPayloadKind"/>s that are supported with the specified payload.</returns>
        internal override IEnumerable<ODataPayloadKind> DetectPayloadKind(
            IODataRequestMessage requestMessage,
            ODataPayloadKindDetectionInfo detectionInfo)
        {
            DebugUtils.CheckNoExternalCallers();
            ExceptionUtils.CheckArgumentNotNull(requestMessage, "requestMessage");
            ExceptionUtils.CheckArgumentNotNull(detectionInfo, "detectionInfo");

            // Metadata is not supported in requests!
            return Enumerable.Empty<ODataPayloadKind>();
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:17,代码来源:ODataMetadataFormat.cs


示例14: Process

 public override void Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)
 {
     switch (this.HttpMethod)
     {
         case HttpMethod.POST:
             this.ProcessCreate(requestMessage.GetStream(), responseMessage);
             break;
         case HttpMethod.PUT:
             this.ProcessUpdate(requestMessage.GetStream(), responseMessage);
             break;
     }
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:MediaStreamHandler.cs


示例15: Process

        public override void Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)
        {
            using (var messageWriter = this.CreateMessageWriter(responseMessage))
            {
                ODataError error;
                HttpStatusCode statusCode;

                this.BuildODataError(out error, out statusCode);
                responseMessage.SetStatusCode(statusCode);
                messageWriter.WriteError(error, true);
            }
        }
开发者ID:chinadragon0515,项目名称:ODataSamples,代码行数:12,代码来源:ErrorHandler.cs


示例16: CreateWriter

        /// <summary>
        /// Creates a writer for the given request message and settings.
        /// </summary>
        /// <param name="requestMessage">The request message.</param>
        /// <param name="writerSettings">The writer settings.</param>
        /// <param name="isParameterPayload">true if the writer is intended to for a parameter payload, false otherwise.</param>
        /// <returns>Newly created writer.</returns>
        internal ODataMessageWriter CreateWriter(IODataRequestMessage requestMessage, ODataMessageWriterSettings writerSettings, bool isParameterPayload)
        {
            Debug.Assert(requestMessage != null, "requestMessage != null");
            Debug.Assert(writerSettings != null, "writerSettings != null");

            this.requestInfo.Context.Format.ValidateCanWriteRequestFormat(requestMessage, isParameterPayload);

            // When calling Execute() to invoke an Action, the client doesn't support parsing the target url
            // to determine which IEdmOperationImport to pass to the ODL writer. So the ODL writer is
            // serializing the parameter payload without metadata. Setting the model to null so ODL doesn't
            // do unecessary validations when writing without metadata.
            var model = isParameterPayload ? null : this.requestInfo.Model;
            return new ODataMessageWriter(requestMessage, writerSettings, model);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:21,代码来源:ODataMessageWritingHelper.cs


示例17: BatchServiceHost

        internal BatchServiceHost(Uri absoluteServiceUri, IODataRequestMessage operationMessage, string contentId, ODataBatchWriter writer, Version maxDataServiceVersion, Version minDataServiceVersion, Version dataServiceVersion) : this(writer)
        {
            this.absoluteServiceUri = absoluteServiceUri;
			this.absoluteRequestUri = RequestUriProcessor.GetAbsoluteUriFromReference(operationMessage.Url, absoluteServiceUri, dataServiceVersion);
            this.requestHttpMethod = operationMessage.Method;
            this.contentId = contentId;
            foreach (KeyValuePair<string, string> pair in operationMessage.Headers)
            {
                this.requestHeaders.Add(pair.Key, pair.Value);
            }
            if (string.IsNullOrEmpty(this.requestHeaders["MaxDataServiceVersion"]))
            {
                this.requestHeaders["MaxDataServiceVersion"] = maxDataServiceVersion.ToString();
            }
            if (string.IsNullOrEmpty(this.requestHeaders["MinDataServiceVersion"]))
            {
                this.requestHeaders["MinDataServiceVersion"] = minDataServiceVersion.ToString();
            }
            this.requestStream = operationMessage.GetStream();
        }
开发者ID:nickchal,项目名称:pash,代码行数:20,代码来源:BatchServiceHost.cs


示例18: Process

        public override void Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)
        {
            try
            {
                var odataPath = this.QueryContext.QueryPath;

                if (this.QueryContext.Target.IsReference && this.QueryContext.Target.TypeKind != EdmTypeKind.Collection)
                {
                    ProcessUpdateEntityReference(requestMessage, responseMessage, odataPath);
                }
                else
                {
                    ProcessUpdateOrUpsertEntity(requestMessage, responseMessage, odataPath);
                }
            }
            catch
            {
                this.DataSource.UpdateProvider.ClearChanges();
                throw;
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:21,代码来源:UpdateHandler.cs


示例19: Process

        public override void Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)
        {
            // TODO: we will need to add server-driven paging for delta link

            object queryResults = this.QueryContext.ResolveQuery(this.DataSource);

            using (var messageWriter = this.CreateMessageWriter(responseMessage))
            {
                IEdmNavigationSource navigationSource = this.QueryContext.Target.NavigationSource;
                IEnumerable iEnumerableResults = queryResults as IEnumerable;

                if (this.QueryContext.Target.NavigationSource != null && this.QueryContext.Target.TypeKind == EdmTypeKind.Collection)
                {
                    IEdmEntitySetBase entitySet = navigationSource as IEdmEntitySetBase;
                    IEdmEntityType entityType = this.QueryContext.Target.ElementType as IEdmEntityType;
                    if (entitySet == null || entityType == null)
                    {
                        throw new InvalidOperationException("Invalid target when query feed.");
                    }
                    GenerateDeltaItemsFromFeed(iEnumerableResults, entitySet, ODataVersion.V4, this.QueryContext.QuerySelectExpandClause);

                    Uri newDeltaLink = null;
                    if (this.PreferenceContext.TrackingChanges)
                    {
                        var newDeltaToken = DeltaContext.GenerateDeltaToken(this.QueryContext.QueryUri, iEnumerableResults, entitySet, this.QueryContext.QuerySelectExpandClause);
                        newDeltaLink = new Uri(string.Format("{0}?{1}={2}", this.ServiceRootUri, ServiceConstants.QueryOption_Delta, newDeltaToken));
                        responseMessage.AddPreferenceApplied(ServiceConstants.Preference_TrackChanging);
                    }
                    ODataDeltaWriter resultWriter = messageWriter.CreateODataDeltaWriter(entitySet, entityType);
                    ResponseWriter.WriteDeltaFeed(resultWriter, this.DeltaItems, this.QueryContext.CountOption, newDeltaLink);

                    resultWriter.Flush();
                }
                else
                {
                    throw Utility.BuildException(HttpStatusCode.Gone);
                }
            }
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:39,代码来源:DeltaHandler.cs


示例20: ODataResponseContext

        public ODataResponseContext(IODataRequestMessage requestMessage, ODataFormat format, ODataVersion version, Uri baseAddress, string serviceOperationName)
        {
            if (requestMessage == null)
            {
                throw Error.ArgumentNull("requestMessage");
            }

            if (baseAddress == null)
            {
                throw Error.ArgumentNull("baseAddress");
            }

            if (String.IsNullOrEmpty(serviceOperationName))
            {
                throw Error.ArgumentNullOrEmpty("serviceOperationName");
            }

            _requestMessage = requestMessage;
            ODataFormat = format;
            ODataVersion = version;
            _baseAddress = baseAddress;
            _serviceOperationName = serviceOperationName;
            IsIndented = true;
        }
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:24,代码来源:ODataResponseContext.cs



注:本文中的IODataRequestMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IODataResponseMessage类代码示例发布时间:2022-05-24
下一篇:
C# IOConnectionInfo类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap