当前位置: 首页>>代码示例>>C#>>正文


C# IDataService.GetSegmentForContentId方法代码示例

本文整理汇总了C#中IDataService.GetSegmentForContentId方法的典型用法代码示例。如果您正苦于以下问题:C# IDataService.GetSegmentForContentId方法的具体用法?C# IDataService.GetSegmentForContentId怎么用?C# IDataService.GetSegmentForContentId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataService的用法示例。


在下文中一共展示了IDataService.GetSegmentForContentId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateFirstSegment

 private static System.Data.Services.SegmentInfo CreateFirstSegment(IDataService service, string identifier, string queryPortion, out bool crossReferencingUrl)
 {
     bool flag;
     crossReferencingUrl = false;
     System.Data.Services.SegmentInfo segment = new System.Data.Services.SegmentInfo {
         Identifier = identifier
     };
     if (segment.Identifier == "$metadata")
     {
         WebUtil.CheckSyntaxValid(queryPortion == null);
         segment.TargetKind = RequestTargetKind.Metadata;
         return segment;
     }
     if (segment.Identifier == "$batch")
     {
         WebUtil.CheckSyntaxValid(queryPortion == null);
         segment.TargetKind = RequestTargetKind.Batch;
         return segment;
     }
     if (segment.Identifier == "$count")
     {
         throw DataServiceException.CreateResourceNotFound(System.Data.Services.Strings.RequestUriProcessor_CountOnRoot);
     }
     segment.Operation = service.Provider.TryResolveServiceOperation(segment.Identifier);
     if (segment.Operation != null)
     {
         return CreateSegmentForServiceOperation(service, queryPortion, segment);
     }
     System.Data.Services.SegmentInfo segmentForContentId = service.GetSegmentForContentId(segment.Identifier);
     if (segmentForContentId != null)
     {
         segmentForContentId.Identifier = segment.Identifier;
         crossReferencingUrl = true;
         return segmentForContentId;
     }
     ResourceSetWrapper wrapper = service.Provider.TryResolveResourceSet(segment.Identifier);
     if (wrapper != null)
     {
         segment.TargetContainer = wrapper;
         segment.TargetResourceType = wrapper.ResourceType;
         segment.TargetSource = RequestTargetSource.EntitySet;
         segment.TargetKind = RequestTargetKind.Resource;
         segment.SingleResult = false;
         if (queryPortion != null)
         {
             ExtractKeyPredicates(queryPortion, segment);
         }
         return segment;
     }
     string nameFromContainerQualifiedName = service.Provider.GetNameFromContainerQualifiedName(identifier, out flag);
     OperationWrapper serviceAction = service.ActionProvider.TryResolveServiceAction(service.OperationContext, nameFromContainerQualifiedName);
     WebUtil.CheckResourceExists(serviceAction != null, identifier);
     return CreateSegmentForServiceAction(null, serviceAction, service, identifier, queryPortion);
 }
开发者ID:nickchal,项目名称:pash,代码行数:54,代码来源:RequestUriProcessor.cs

示例2: IsCrossReferencedSegment

 internal static bool IsCrossReferencedSegment(System.Data.Services.SegmentInfo segmentInfo, IDataService service)
 {
     return (segmentInfo.Identifier.StartsWith("$", StringComparison.Ordinal) && (service.GetSegmentForContentId(segmentInfo.Identifier) != null));
 }
开发者ID:nickchal,项目名称:pash,代码行数:4,代码来源:Deserializer.cs

示例3: IsCrossReferencedSegment

        /// <summary>
        /// Test if the given segment is a cross referenced segment in a batch operation
        /// </summary>
        /// <param name="segmentInfo">Segment in question</param>
        /// <param name="service">service instance</param>
        /// <returns>True if the given segment is a cross referenced segment</returns>
        internal static bool IsCrossReferencedSegment(SegmentInfo segmentInfo, IDataService service)
        {
            if (segmentInfo.Identifier.StartsWith("$", StringComparison.Ordinal) && service.GetSegmentForContentId(segmentInfo.Identifier) != null)
            {
                return true;
            }

            return false;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:15,代码来源:Deserializer.cs

示例4: CreateUriParserWithBatchReferenceCallback

        /// <summary>
        /// Create Uri Parser with batch reference callback
        /// </summary>
        /// <param name="service">Data service for which the request is being processed.</param>
        /// <param name="absoluteRequestUri">Request uri that needs to get processed.</param>
        /// <returns>Created ODataUriParser</returns>
        internal static ODataUriParser CreateUriParserWithBatchReferenceCallback(IDataService service, Uri absoluteRequestUri)
        {
            var model = service.Provider.GetMetadataProviderEdmModel();
            var parser = new ODataUriParser(model, service.OperationContext.AbsoluteServiceUri, absoluteRequestUri)
            {
                Settings =
                {
                    MaximumExpansionDepth = service.Configuration.MaxExpandDepth,
                    MaximumExpansionCount = service.Configuration.MaxExpandCount,
                }
            };

            if (UrlConvention.Create(service).GenerateKeyAsSegment)
            {
                parser.UrlConventions = ODataUrlConventions.KeyAsSegment;
            }

            // configure the callback for handling batch cross-referencing segments ($0 etc).
            parser.BatchReferenceCallback = contentId =>
            {
                var segmentForContentId = service.GetSegmentForContentId(contentId);
                if (segmentForContentId == null)
                {
                    return null;
                }

                return new BatchReferenceSegment(
                    contentId,
                    model.EnsureSchemaType(segmentForContentId.TargetResourceType),
                    model.EnsureEntitySet(segmentForContentId.TargetResourceSet));
            };

            return parser;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:40,代码来源:RequestUriProcessor.cs


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