本文整理汇总了C#中Microsoft.OData.Service.Providers.ResourceType.GetMinimumResponseVersion方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceType.GetMinimumResponseVersion方法的具体用法?C# ResourceType.GetMinimumResponseVersion怎么用?C# ResourceType.GetMinimumResponseVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.OData.Service.Providers.ResourceType
的用法示例。
在下文中一共展示了ResourceType.GetMinimumResponseVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateResponseVersionForPostMediaResource
/// <summary>
/// Check and updates the response version for POST MR operation.
/// </summary>
/// <param name="resourceType">Resource type for the MLE.</param>
/// <param name="dataService">Data service instance.</param>
internal void UpdateResponseVersionForPostMediaResource(ResourceType resourceType, IDataService dataService)
{
Debug.Assert(dataService != null && dataService.OperationContext.RequestMessage.HttpVerb == HttpVerbs.POST, "dataService != null && dataService.OperationContext.RequestMessage.AstoriaHttpVerb == AstoriaVerbs.POST");
Debug.Assert(this.LastSegmentInfo != null, "LastSegmentInfo != null");
Debug.Assert(this.LastSegmentInfo.TargetResourceSet != null, "LastSegmentInfo.TargetResourceSet != null");
// Raise response version due to features use by the response payload
// This should only happen if we are going to write a payload in the response. For POST this is done by default
// unless the Prefer header is set to NoContent.
if (!this.Preference.ShouldNotIncludeResponseBody)
{
this.InitializeVersion(dataService);
// we are getting the MinimumPayloadVersion from the type because we know the specific type so we
// can get a more specific version this way
ResourceSetWrapper resourceSet = this.LastSegmentInfo.TargetResourceSet;
Version minimumPayloadVersion = resourceType.GetMinimumResponseVersion(dataService, resourceSet);
this.VerifyAndRaiseResponseVersion(minimumPayloadVersion, dataService);
}
else
{
Debug.Assert(
this.ResponseVersion >= VersionUtil.Version4Dot0,
"If the return-no-content Prefer header is applied, the response version must be at least 4.0.");
}
}
示例2: UpdateAndCheckRequestResponseDSV
/// <summary>
/// Bump the minimum DSV requirement based on the specifics of the given resource type.
/// </summary>
/// <param name="resourceType">Resource type to inspect</param>
/// <param name="topLevel">True if resourceType is the type for the top level element in the payload.</param>
protected void UpdateAndCheckRequestResponseDSV(ResourceType resourceType, bool topLevel)
{
Debug.Assert(this.Service != null, "this.Service != null");
Debug.Assert(this.Service.Provider != null, "this.Service.Provider != null");
Debug.Assert(resourceType != null, "Must have valid resource type");
Debug.Assert(resourceType.ResourceTypeKind == ResourceTypeKind.EntityType, "resourceType.ResourceTypeKind == ResourceTypeKind.EntityType");
Debug.Assert(this.RequestDescription != null, "this.RequestDescription != null");
Debug.Assert(this.RequestDescription.LastSegmentInfo != null, "this.RequestDescription.LastSegmentInfo != null");
Debug.Assert(this.RequestDescription.LastSegmentInfo.TargetResourceSet != null, "this.RequestDescription.LastSegmentInfo.TargetContainer != null");
// Raise the response version if a response will be sent.
if (topLevel && this.ResponseWillBeSent)
{
// We only raise the response version here but not minimum request version.
// Because named stream links are not allowed on the request payload
// and we allow collection properties in the request payload regardless of the request DSV since
// we can easily recognize them (either having m:type="Collection()", or being declared in our metadata as collection)
// and thus there's no chance to misinterpret the payload.
//
// we are getting the MinimumPayloadVersion from the type because we know the specific type so we
// can get a more specific version this way
ResourceSetWrapper resourceSet = this.RequestDescription.LastSegmentInfo.TargetResourceSet;
Version minimumPayloadVersion = resourceType.GetMinimumResponseVersion(this.Service, resourceSet);
if (!this.IsAtomRequest)
{
minimumPayloadVersion = resourceType.GetMinimumResponseVersion(this.Service, resourceSet);
}
this.RequestDescription.VerifyAndRaiseResponseVersion(minimumPayloadVersion, this.Service);
}
}