/// <summary>Gets a string with methods allowed on the target for the <paramref name="description"/>.</summary> /// <param name="configuration">configuration object which has the data</param> /// <param name="description">Description with target.</param> /// <returns>A string with methods allowed on the description; possibly null.</returns> internal static string GetAllowedMethods(DataServiceConfiguration configuration, RequestDescription description) { Debug.Assert(description != null, "description != null"); Debug.Assert( description.TargetKind != RequestTargetKind.Nothing, "description.TargetKind != RequestTargetKind.Void - otherwise it hasn't been determined yet"); Debug.Assert( description.TargetKind != RequestTargetKind.VoidOperation, "description.TargetKind != RequestTargetKind.VoidOperation - this method is only for containers"); if (description.TargetKind == RequestTargetKind.Metadata || description.TargetKind == RequestTargetKind.ServiceDirectory) { return XmlConstants.HttpMethodGet; } if (description.TargetKind == RequestTargetKind.Batch) { return XmlConstants.HttpMethodPost; } int index = description.GetIndexOfTargetEntityResource(); Debug.Assert(index >= 0 && index < description.SegmentInfos.Count, "index >=0 && index <description.SegmentInfos.Count"); ResourceSetWrapper container = description.SegmentInfos[index].TargetResourceSet; return GetAllowedMethods(configuration, container, description); }
/// <summary> /// Calls the Execution provider to invoke the request expressions for the current request /// </summary> /// <param name="description">Request description.</param> /// <param name="service">Service instance.</param> private static void InvokeRequestExpression(RequestDescription description, IDataService service) { Debug.Assert(description != null, "description != null"); Debug.Assert(service != null, "service != null"); HttpVerbs httpVerb = service.OperationContext.RequestMessage.HttpVerb; bool isPostOperationRequest = httpVerb == HttpVerbs.POST && description.TargetSource == RequestTargetSource.ServiceOperation; if (httpVerb.IsQuery() || isPostOperationRequest) { SegmentInfo segmentToInvoke = description.LastSegmentInfo; if (httpVerb.IsQuery() && description.TargetSource == RequestTargetSource.Property) { // GET ~/Customer(1)/Address/State for example we need to execute the expression at the resource level, i.e. Customer(1). // Then we call IDSQP.GetValue() to get the property values for Address and State. segmentToInvoke = description.SegmentInfos[description.GetIndexOfTargetEntityResource()]; } if (segmentToInvoke.RequestExpression != null && segmentToInvoke.RequestEnumerable == null) { segmentToInvoke.RequestEnumerable = service.ExecutionProvider.GetResultEnumerableFromRequest(segmentToInvoke); } } }