예제 #1
0
 private RootProjectionNode GetRootProjectionNode()
 {
     if (this.rootProjectionNode == null)
     {
         this.rootProjectionNode = new RootProjectionNode(this.description.LastSegmentInfo.TargetContainer, this.topLevelOrderingInfo, null, this.skipCount, this.topCount, null, this.expandPaths, this.description.TargetResourceType);
     }
     return(this.rootProjectionNode);
 }
예제 #2
0
 private RequestQueryProcessor(IDataService service, RequestDescription description)
 {
     this.service               = service;
     this.description           = description;
     this.orderApplied          = false;
     this.skipCount             = null;
     this.topCount              = null;
     this.queryExpression       = description.RequestExpression;
     this.filterQueryApplicable = (((description.TargetKind == RequestTargetKind.Resource) || (description.TargetKind == RequestTargetKind.OpenProperty)) || (description.TargetKind == RequestTargetKind.ComplexObject)) || (description.CountOption == RequestQueryCountOption.ValueOnly);
     this.setQueryApplicable    = ((description.TargetKind == RequestTargetKind.Resource) && !description.IsSingleResult) || (description.CountOption == RequestQueryCountOption.ValueOnly);
     this.pagingApplicable      = (((description.TargetKind == RequestTargetKind.Resource) && !description.IsSingleResult) && ((description.CountOption != RequestQueryCountOption.ValueOnly) && !description.IsRequestForEnumServiceOperation)) && ((service.OperationContext.Host.HttpVerb == HttpVerbs.GET) || (description.SegmentInfos[0].TargetSource == RequestTargetSource.ServiceOperation));
     this.appliedCustomPaging   = false;
     this.expandPaths           = null;
     this.expandPathsAsText     = null;
     this.rootProjectionNode    = null;
     this.orderingParser        = null;
     this.topLevelOrderingInfo  = null;
 }
예제 #3
0
        /// <summary>Initializes a new RequestDescription based on an existing one.</summary>
        /// <param name="other">Other description to base new description on.</param>
        /// <param name="queryResults">Query results for new request description.</param>
        /// <param name="rootProjectionNode">Projection segment describing the projections on the top level of the query.</param>
        internal RequestDescription(
            RequestDescription other,
            IEnumerable queryResults,
            RootProjectionNode rootProjectionNode)
        {
            Debug.Assert(
                queryResults == null || other.SegmentInfos != null,
                "queryResults == null || other.SegmentInfos != null -- otherwise there isn't a segment in which to replace the query.");
            Debug.Assert(
                rootProjectionNode == null || queryResults != null,
                "rootProjectionNode == null || queryResults != null -- otherwise there isn't a query to execute and expand");

            this.containerName            = other.containerName;
            this.mimeType                 = other.mimeType;
            this.usesContainerName        = other.usesContainerName;
            this.resultUri                = other.resultUri;
            this.segmentInfos             = other.SegmentInfos;
            this.rootProjectionNode       = rootProjectionNode;
            this.countOption              = other.countOption;
            this.SkipTokenExpressionCount = other.SkipTokenExpressionCount;
            this.SkipTokenProperties      = other.SkipTokenProperties;
            this.countValue               = other.countValue;

            this.requireMinimumVersion = other.requireMinimumVersion;
            this.responseVersion       = other.responseVersion;
            this.maxFeatureVersion     = other.maxFeatureVersion;

            if (queryResults == null)
            {
                this.segmentInfos = other.SegmentInfos;
            }
            else
            {
                int         lastSegmentIndex = other.SegmentInfos.Length - 1;
                SegmentInfo lastSegmentInfo  = other.SegmentInfos[lastSegmentIndex];
                lastSegmentInfo.RequestEnumerable = queryResults;
            }
        }
예제 #4
0
 private void CheckExpandPaths()
 {
     if (this.expandPathsAsText.Count > 0)
     {
         if (this.queryExpression == null)
         {
             throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_QueryExpandOptionNotApplicable);
         }
         if (this.description.TargetResourceType.ResourceTypeKind == ResourceTypeKind.Collection)
         {
             throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_QueryExpandOptionNotApplicable);
         }
     }
     this.expandPaths = new List <ExpandSegmentCollection>(this.expandPathsAsText.Count);
     for (int i = this.expandPathsAsText.Count - 1; i >= 0; i--)
     {
         ExpandSegmentCollection item = this.CheckSingleExpandPath(this.expandPathsAsText[i]);
         if (item == null)
         {
             this.expandPathsAsText.RemoveAt(i);
         }
         else
         {
             this.expandPaths.Add(item);
             ExpandedProjectionNode rootProjectionNode = this.GetRootProjectionNode();
             for (int j = 0; j < item.Count; j++)
             {
                 ExpandSegment          segment = item[j];
                 ExpandedProjectionNode node2   = rootProjectionNode.AddExpandedNode(segment);
                 this.GetRootProjectionNode().ExpansionOnDerivedTypesSpecified |= rootProjectionNode.HasExpandedPropertyOnDerivedType;
                 rootProjectionNode = node2;
             }
             this.GetRootProjectionNode().ExpansionsSpecified = true;
         }
     }
 }
예제 #5
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));
         }
     }
 }