Beispiel #1
0
 private void ApplyProjectionsToExpandTree(List <List <string> > selectPathsAsText)
 {
     for (int i = selectPathsAsText.Count - 1; i >= 0; i--)
     {
         List <string>          list = selectPathsAsText[i];
         ExpandedProjectionNode rootProjectionNode = this.GetRootProjectionNode();
         ResourceType           type = null;
         for (int j = 0; j < list.Count; j++)
         {
             bool   flag2;
             string containerQualifiedName = list[j];
             bool   lastPathSegment        = j == (list.Count - 1);
             rootProjectionNode.ProjectionFound = true;
             if (containerQualifiedName == "*")
             {
                 rootProjectionNode.ProjectAllImmediateProperties = true;
                 break;
             }
             if (this.service.Provider.GetNameFromContainerQualifiedName(containerQualifiedName, out flag2) == "*")
             {
                 rootProjectionNode.ProjectAllImmediateOperations = true;
                 break;
             }
             ResourceType     previousSegmentResourceType = type ?? rootProjectionNode.ResourceType;
             ResourceProperty property = previousSegmentResourceType.TryResolvePropertyName(containerQualifiedName);
             if (property == null)
             {
                 type = WebUtil.ResolveTypeIdentifier(this.service.Provider, containerQualifiedName, previousSegmentResourceType, type != null);
                 if (type != null)
                 {
                     this.description.VerifyProtocolVersion(RequestDescription.Version3Dot0, this.service);
                     continue;
                 }
                 Func <OperationWrapper, bool> predicate = null;
                 string           serviceActionName      = this.service.Provider.GetNameFromContainerQualifiedName(containerQualifiedName, out flag2);
                 OperationWrapper operation = null;
                 if (!previousSegmentResourceType.IsOpenType || flag2)
                 {
                     if (predicate == null)
                     {
                         predicate = o => o.Name == serviceActionName;
                     }
                     operation = this.service.ActionProvider.GetServiceActionsByBindingParameterType(this.service.OperationContext, previousSegmentResourceType).SingleOrDefault <OperationWrapper>(predicate);
                 }
                 if (operation != null)
                 {
                     rootProjectionNode.AddOperation(operation);
                     if (!lastPathSegment)
                     {
                         throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_ServiceActionMustBeLastSegmentInSelect(containerQualifiedName));
                     }
                     continue;
                 }
                 if (!previousSegmentResourceType.IsOpenType)
                 {
                     throw DataServiceException.CreateSyntaxError(System.Data.Services.Strings.RequestUriProcessor_PropertyNotFound(previousSegmentResourceType.FullName, containerQualifiedName));
                 }
                 if (!lastPathSegment)
                 {
                     throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.OpenNavigationPropertiesNotSupportedOnOpenTypes(containerQualifiedName));
                 }
             }
             rootProjectionNode = ApplyProjectionForProperty(rootProjectionNode, containerQualifiedName, property, previousSegmentResourceType, lastPathSegment);
             type = null;
         }
         if (type != null)
         {
             throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_QueryParametersPathCannotEndInTypeIdentifier("$select", type.FullName));
         }
     }
 }