Beispiel #1
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;
 }
Beispiel #2
0
 private void ApplyCustomPaging(string skipToken)
 {
     if (!string.IsNullOrEmpty(skipToken))
     {
         KeyInstance instance;
         WebUtil.CheckSyntaxValid(KeyInstance.TryParseNullableTokens(skipToken, out instance));
         ParameterExpression parameterForIt         = Expression.Parameter(this.description.LastSegmentInfo.TargetResourceType.InstanceType, "it");
         RequestQueryParser.ExpressionParser parser = new RequestQueryParser.ExpressionParser(this.service, this.description, parameterForIt, string.Empty);
         object[] skipTokenValues = new object[instance.PositionalValues.Count];
         int      num             = 0;
         foreach (object obj2 in instance.PositionalValues)
         {
             skipTokenValues[num++] = parser.ParseSkipTokenLiteral((string)obj2);
         }
         this.CheckAndApplyCustomPaging(skipTokenValues);
         this.description.VerifyProtocolVersion(RequestDescription.Version2Dot0, this.service);
         this.description.VerifyRequestVersion(RequestDescription.Version2Dot0, this.service);
     }
     else
     {
         this.CheckAndApplyCustomPaging(null);
     }
 }
Beispiel #3
0
        private void ObtainOrderingExpressions()
        {
            StringBuilder builder = new StringBuilder(this.service.OperationContext.Host.GetQueryStringItem("$orderby"));

            if (builder.Length > 0)
            {
                this.CheckSetQueryApplicable();
            }
            ResourceType targetResourceType = this.description.TargetResourceType;

            this.topLevelOrderingInfo = new OrderingInfo(this.IsStandardPaged);
            if ((this.IsStandardPaged || this.topCount.HasValue) || this.skipCount.HasValue)
            {
                string str = (builder.Length > 0) ? "," : string.Empty;
                foreach (ResourceProperty property in this.description.TargetResourceSet.GetKeyPropertiesForOrderBy())
                {
                    builder.Append(str).Append(property.Name).Append(' ').Append("asc");
                    str = ",";
                }
            }
            string str2 = builder.ToString();

            if (!string.IsNullOrEmpty(str2))
            {
                ParameterExpression parameterForIt = Expression.Parameter(targetResourceType.InstanceType, "element");
                this.orderingParser = new RequestQueryParser.ExpressionParser(this.service, this.description, parameterForIt, str2);
                foreach (OrderingExpression expression2 in this.orderingParser.ParseOrdering())
                {
                    this.topLevelOrderingInfo.Add(new OrderingExpression(Expression.Lambda(expression2.Expression, new ParameterExpression[] { parameterForIt }), expression2.IsAscending));
                }
                if (this.IsStandardPaged)
                {
                    this.description.SkipTokenExpressionCount = this.topLevelOrderingInfo.OrderingExpressions.Count;
                    this.description.SkipTokenProperties      = NeedSkipTokenVisitor.CollectSkipTokenProperties(this.topLevelOrderingInfo, targetResourceType);
                }
            }
        }